|
|
?????abxxxab????? abab output: 3 answer: 4 I wrote program on C++ and got WA1. I rewrote program on Pascal and got AC. I think my error in input string. How do i read lines? My attempts: 1) int c; n=0; while ((c = getchar()) != EOF) { if(c=='\n') break; s[++n]=c; } m=0; while ((c = getchar()) != EOF) t[++m]=(char)c; 2) void Input() { int c; scanf("%c",&c); n=0; while (c!='\n') { s[++n]=c; scanf("%c",&c); } m=0; while ((c = getchar()) != EOF) t[++m]=(char)c; } Probably <string> will help, but i prefer work with index>=1. Edited by author 22.06.2017 23:44 Edited by author 22.06.2017 23:44 My AC program gives wrong answer on this test: ?????xy????? xyxy My answer: 3 Right answer: 4 Edited by author 13.11.2012 12:52 try this test case : Input: ababababab aba Output: 4 why WA #3, please, give me any test ... Edited by author 12.11.2012 20:03 I have a problem Crash(access violation) help me please Sorry for poor English In 2 sample: Arch?????rchibaldIronfist Archibald but we can put Archibald from 1st position and from 9th position. Why answer is 1? Because it cannot appear on BOTH 1 and 9 positions. Can somebody give hints to solve this task? Conflict graph may help. Positions of possible substrings are vertices and two positions conflict if they can not be simultaneously. Answer= max number of independent vertices. Also let relation a<b means that position is before of position b and they don't conflict.Then a<b,b<c=> a<c so we have an order. Answer is a height of ordered structure. Edited by author 08.10.2011 19:07 Just easy DP. But Dp may be difficult- problem of 35 test. When poset is used and standard dfs for it's height we have Ac without any problems. Need for some tests :( Edited by author 24.09.2011 16:05 me 2 Was using simple algorithm. complexity O((n - m + 1) * m). WA 35 Try this: ?????ab abab Ans - 2. Thanks... not too much exp in string algo( Does it suppose some KMP-algo modification? Edited by author 24.09.2011 20:56 My program passed this test but still gets WA 35 :( Your DP is wrong. I also got WA 35 in my first solution. it was compiled fine in my system... but i dont know why it was showing compilation error when i submit... please help me !! |
|
|