|
|
I have got ac by return NO when k > 20, but how to prove it? What is algo? =) simple DP: int leftPos[char][pos] position of char which is left or equal of pos int lastPos[mask] : for substring s[lastPos[mask]..s.length()-1] we can get all name of sportman with char which is in mask. =) Can M*N*2^(n) dp solution be improved, so that it passes all test? ( Probably it could be M*2^(n)), or it's wrong and I have to think on completely new solution? Yes. It can be easily optimized to O(N*log|S|*2^N).(|S| - is the length of the word). But even O(N*|S|*2^N) solution can pass all tests. Well, my n * s * 2^n solution didn't pass until I added a (as it turned out) curcial optimization. Edited by author 27.07.2009 03:08 My solution is s*2^n ... it runs extremely fast with a very short code :) Edited by author 01.08.2010 16:59 Edited by author 01.08.2010 16:59 I don't print 'NO' if N is large, I check it normally, but I still get WA #73? Whats the trick with this test? Is there a word that is 'YES' for N>18? Edited by author 03.05.2009 00:44 My AC program assumes there is no string with N>18, so debug your code Thanks, I had a silly bug. Hi, For large test cases like n = 18 etc, if the answer is Yes, does that mean that our program will need to test for all the 18 factorial possibilities ? That's like running the loop 10^16 times which is impossible within 3 seconds ! Thanks NO. there are some pattern that satisfy for n>8 Edited by author 20.12.2008 20:49 Suppose secuence like abcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklmabcdefghjklm etc.. I have WA 70. please tell me is there any test case where n == 18 && answer == "YES"? int test 70 n == 18 and answer is YES ;) Edited by author 28.12.2008 21:37 Edited by author 28.12.2008 21:38 We analysed AC solutions of this problem from online contest and add new test. 3 solutions from contest output wrong answer on it. i don't know why WA in test 8. please help try this test: 4 abcabcab thx very much i can find the mistake. but i don't know how to correct I have faced the same problem. The test 8 - WA. On the test: 4 abcabcab The algorithm answers NO i correct it for this problem it must answer YES. i use another algorithm but got WA in test 28. plz. help thx. Why on the test: 4 abcabcab The answer - YES? In the example there is no letter d |
|
|