Edited by author 27.02.2022 15:58 Input: 3 '╣' like '[╣-I]' '╣' like '╣' '╣' like '_' Output: YES YES YES My AC solution gives NO to the first one; there should be no tests where the start character in a range is greater than the end character. input: 1 'a-z' like 'a-z' output: YES Edited by author 03.07.2019 23:01 Edited by author 03.07.2019 23:01 Hi, I have tried like million times different combinations, and it always gives wrong answer, always on 6. case. Does anyone have 6. case? Does any anyone have any idea what kind of strings/patterns are in 6. case? Thanks in advance In test 6 there are several consecutive '%' chars in the pattern. I got TLE, then replaced "%%" with "%" and passed. I'm guessing you can get WA on test 6 if you're not matching the empty string with "%". Should I care of patterns with incomplete square braces? For example 'a[b' (and probably treat '[' as a regular character for matching. Or there is no such tests? No such tests. (I like to put asserts in unclear cases like these and see if they fire) No [] or [^] either How to deal with case like this ' ' like ' like ' like ' like ' 'like ' it can be splitted as ( ) & ( like ' like ' like ' 'like ) or ( ' like ) & ( like ' like ' 'like ) or ( ' like ' like ) & ( like ' 'like ) or ( ' like ' like ' like ) & ( 'like ) Can you clarify this statement Inner entrance of apostrophe symbol (ASCII 39) into string or template is encoded by double apostrophe symbol And if it's true the case ''hi'' like ''hi'' will be changed to '"hi'' like '"hi' Am I right? Then how is this case possible? '''''' like '_''' The apostrophe symbol (ASCII 39) if appear in string or template will be double (now it becomes 2 successive apostrophe symbols). The English problem statement is wrong to me since it made us think that ASCII 39 is replaced by ASCII 34 or something. But in fact, ASCII 39 is replaced by two ASCII 39. At least, I got AC after using my above interpretation. In fact, the string are two apostrophe symbols, and the template are an underline and an apostrophe symbol. An underline can match any single character, and the other apostrophe can match the second apostrophe. So, the answer is 'YES'. Hi, My program pass all local tests but crashes after submit on test #3. Most probably I miss some boundary or weird pattern case. I use C++ and I took into account the fact that char's over 127 are converted to negative integers. Do you have any hint? UPD: My local test file: 31 '' like '%' '' like '' 'a' like 'a%' '·' like '·' 'f' like '[z-a]' 'a' like '[a-]' '·' like '[·a]' 'abcde' like 'a' 'abcde' like 'a%' 'abcde' like '%a' 'abcde' like 'b' 'abcde' like 'b%' 'abcde' like '%b' '25%' like '_5[%]' '_52' like '[_]5%' 'ab' like 'a[a-cdf]' 'ad' like 'a[a-cdf]' 'ab' like 'a[-acdf]' 'a-' like 'a[-acdf]' '[]' like '[[]]' '''''' like '_''' 'U' like '[^a-zA-Z0-9]' 'like' like 'like' ''' '' ' like ''' ''%' '[' like '[[]' '%' like '[%]' '_' like '[_]' ']' like ']' '^' like '^' 'like' like 'like' ''' '' ' like ''' ''%' if you get WA on test #2, then try to use unsigned char* instead char* I have done it with char s[], you don't have to use unsigned char s[] !!! I used scanf ... Edited by author 03.04.2010 00:08 I had WA2 with some test like this 'a' like '[a-]' YES Because there may be spaces in the input, "scanf("%s")" may not be accepted... 2 'like' like 'like' ''' '' ' like ''' ''%' YES YES Tests may also have spaces, so it is a confusing question to determine how to get the string and the pattern. I got 14 WA on this question, and finally AC. QWQ Edited by author 14.10.2015 20:17 What are answers for following comparisions? '[]' like '[]' '' like '[]' 'a' like '[--z]' 'b' like '[c-a]' '-' like '[a-f-h]' 'g' like '[a-f-h]' Thank you for your opinion... Just read the Excel, or Access rules about operator "Like", some problems will disappear. Add some success to this and you will be accepted! As this problem's statement is really hard to interpret unambiguously, I've decided to make this attempt to explain my view on it, which seems to be the one that authors meant. Here’s the list of notes that make the problem more clear: in template: 1. Brackets ‘[]’ have the highest priority. Find the leftmost ‘[‘, then find the first ‘]’ after it; you can assume that these two brackets strictly correspond to each other, i.e. can’t be considered to correspond to any other brackets. Then find the first opening bracket after current closing one and so on. 2. Such templates, as [] and [^] are incorrect and don’t happen in test cases. 3. Given an opening bracket [ and a corresponding closing bracket ], let’s consider the string S between them. As Vladimir Yakovlev already stated, special characters '[', '%' and '_' mean themselves when included in brackets. Now, let’s describe a boolean function F(c,s), that determines whether template s matches character c. "Del(s,k)" will denote a function, that returns the tail of s starting from position k+1 inclusively. We shall also need a boolean function G: F: If s[1]='^', Then F(c,s):=Not G(c,Del(s,1)), Else F(c,s):=G(c,s) G: If s[2]='–' and length(s)>=3 Then G(c,s):=G(c,Del(s,3)) Or (s[1]<=c<=s[3]) Else G(c,s)=G(c,Del(s,1)) Or (s[1]=c) To my mind, these rules do make the problem statement clear and have nothing to deal with posting Source code, so I hope moderators won’t delete this message. I also want to say thank you to the person posting under nick "I have answers to all your questions :)" for helping people on this problem. In fact, your posts helped me to understand it. Thank you very much for your help. I can't imagine how much time it would take me to understand all this stuff. I think that the problem statement should be fixed. Or, should have the link to your post :) Thank you for formalized statement =) very useful! The problem unexpectedly dosn't contain very tricky tests. Additionally to forum's examples I add the next: 1. Empty string corresponds with '%%%%%%%%' and so on and with empty pattern also; 2. 'a'~'%a' 3. String may contain many "like" substrings . For defining right position dublicable inner '-characters play key role; 4. Dp-method is veru useful, when we are going from ends of strings to their beginnings. Edited by author 11.07.2007 17:24 Dp-method is veru useful, when we are going from ends of strings to their beginnings. My idea is to split the template to multiple templates with no '%', and then search using some modifications of Knuth-Morris-Pratt (except for the first/last template, if there is no '%' at the beginning/end). I just don't know how fast will it be, because I have not coded it yet... DP-method is a good idea =) But I have solution without DP which works for one query as O(max(len1,len2)^2), where len1,len2 - length of string/pattern. Greedy approach only :) And in practise this method works more faster then O(max(len1,len2)^2). Look at rating of best solutions (0.001 sec VS 0.921 sec with DP). If you want I could tell you about my method. Edited by author 07.08.2015 20:01 'ab' like '[a]b' 'ab' like '%b' 'ab' like '%%b' 'ab' like '%%%b' 'ab' like '%%%b%' 'ab' like '%%%b%%' 'b' like '%%' Edited by author 01.09.2010 00:37 :) all answers should be YES What is the right answer for the given string? Correct answer for such string is YES When reading the input, like this: char *Input; cin.getline(...); the chars with ASCII code larger than 127 will become negative integers, for example, if the ASCII code is SUPPOSED to be 160, it will turn out to be 160-128. Fix this trick, and you will get AC. One more, this article will help you VERY MUCH if you don't really understand the problem statements. http://acm.timus.ru/forum/thread.aspx?space=1&num=1177&id=10577&upd=632900666745579610 (It can be found just on the BOARD.) GOOD LUCK~ please give me source kostan3@spaces.ru Contradictions: ''' like ' like ''' 'a' like '[a^a]' '#' like '!--0' 'd' like 'a-c-e' and so forth ... In the condition you need to specify that these tests are not available. answer from Anatoly: Reduce pattern parts of "%%%%%%" to "%". It extremely raises performance of regex engine. It's really helps. From TLE #6 to AC I don't know how to solve it, but I got AC because C#'s regular expression engine knows ;) How speed up C#'s regular expression engine? I have TL #6 and use Regex.IsMatch method Reduce pattern parts of "%%%%%%" to "%". It extremely raises performance of regex engine. Any idea why I could get WA 4 ? All the tests I gave were ok. Edited by author 16.04.2010 23:25 try this '-' like '[a-b]' maybe it should be no. I got ac just modified it. |
|