WpKRwvgKenn output shold be "WpKRwvgKenneKgvwRKpW" not "WpKRwvgKennneKgvwRKpW" WA4: s1 is already palindrome. ex: aba ababa WA7: s1 consist of only one character. ex: a aa abbb answer: abbba abbbb answer: abbbba Edited by author 25.11.2020 01:48 Edited by author 25.11.2020 01:50 An easy and simple o(n) solution exists. pretty basic has anybody got WA8 too? I tried all tests in forum but it didn't help :( Be careful when you implement Manacher's algorithm, when you copy the ready part for the second part, don't forget making all the needed changes, I forgot changing just one sign ! once I've solved this exercise, but know a vontto make my algorithm better. I've forced whith WA#12. Could you tell me this test? I've solved it!!))) if you have the same problem, try test: 1233345333 ansver: 12333453335433321 It may be caused by conflicts... (Sorry for my poor English I've been wa on this case for a long time: abaabaaba The right answer is abaabaabaaba Can anyone please suggest the test case which might give me WA35... I have used string , also tried with character array... and KMP algorithm ..... please do reply Edited by author 27.08.2018 13:31 Aren't 'abaabaaba' a palindrome? Try this test: a Your output should be: aa Good luck! Thank you! You is good man! I had WA25 when used char[20002]; After changed to char[30002] got AC. Help me WA4? #include <iostream> #include <string> #include <string.h> #include <algorithm> using namespace std; string S, ss, s; int k, l, r, mid; int main(){ cin >> S; int n = S.size(); if(n == 1){ cout << S; return 0; } for (int i = n - 1; i >= 0; i --){ k = n - i; if(i - k >= 0){ ss = S.substr(i, k); s = S.substr(i - k, k); reverse(s.begin(), s.end()); //cout << ss << ' ' << s << endl; if(ss == s){ l = i - k; mid = i; r = i + k; continue; } } k --; if(i - k >= 0){ ss = S.substr(i + 1, k); s = S.substr(i - k, k); reverse(s.begin(), s.end()); //cout << ss << ' ' << s << endl; if(ss == s){ l = i - k; mid = i; r = i + k; } } } //cout << l << ' ' << r << endl; if(!l && !r || (l == 0 && r == n - 1)){ s = S.substr(0, n - 1); cout << S; reverse(s.begin(), s.end()); cout << s; } else{ s = S.substr(0, l); reverse(s.begin(), s.end()); cout << S << s; } return 0; } Hello, I've not found a topic about this test. Does anyone know what is it? I'm just searching from the half of the string to find where can be the center of a palindom. Thank you Can anyone please suggest the test case which might give me WA35... I have used string , also tried with character array... and KMP algorithm ..... please do reply My solution was rejudged and I got WA 35 :) They added tests against hashes modulo 2^64. ADMINSTRATOR HELP PLEASE !!!!!!!!!!!! IT'S MY COD var a:array [1..20010] of char; i,j,k,n,w:integer; r:char; s:string; f:boolean; g:text; t:integer; procedure solve; label 1; var e:integer; begin f:=false; t:=0; for k:=1 to n+i do if (a[k]<>a[n+i-k+1]) then goto 1; f:=true; 1: end; {IMPORTANT PART} Begin assign(g,'input.txt'); reset(g); while not eof(g) do begin readln(g,s); n:=0; for i:=1 to length(s) do begin n:=n+1; a[n]:=s[i]; end; i:=0; repeat solve; if not(f) then begin i:=i+1; for j:=n+i downto n+1 do begin a[j]:=a[j-1]; end; a[n+1]:=a[i]; solve; end; until f; end; // close(g); for j:=1 to n+i do write(a[j]); readln;readln; end. REAL MADRID LUCK THE BEST CLUB Me too!!! program Ural1354; var s:string; a,b,l:longint; begin readln(s); l:=length(s); a:=1; while a<l do begin if s[a]<>s[l] then begin s:=s+' '; for b:=length(s) downto l+2 do s[b]:=s[b-1]; inc(l); s[l]:=s[a]; end; inc(a);dec(l); end; writeln(s); end. You are to find a nonempty word S2 if the input is palindrome... Test#4 abaabaaba ans: abaabaaba //for WA4, because S2 must be not empty! abaabaabaaba //for AC Edited by author 25.11.2011 17:57 I have the same answer, but still get WA4. What the problem? That's not the answer my friend. This is correct: abaabaaba abaababaaba As you see, your solution add three characters. Mine add only two. Greetings! nope, you should print S1 S2, as you see in your answer there is not clearly S1 Tested with already palindrome (as said before), any ideas? For input: aba it will write: ababa and for: abba -> abbabba I've tried this problem with hashing but I get WA on test 12. Anyone else has tried this with Hashing?? or even better get AC Yeah, got AC with hashing :) Edited by author 17.06.2015 19:31 Hi, Does anyone know what the test case is? I've tried my solution against the following, and they seem to be correct. A little lost right now. "No", "OnLine", "AbabaAab", "abaabaaba", "2101221012", "122212221", "A", "AA", "aba", "saaasaaas", "babab" Solutions ========= NoN OnLineniLnO AbabaAababA abaabaabaaba 210122101221012 1222122212221 AA AAA ababa saaasaaasaaas bababab Thanks! Edited by author 03.03.2012 08:35 I have wa5 too! try test qwertew Answer is qwertewetrewq or not qwertewq I have WA#1 but algo was right. I use this construction: import qualified Data.ByteString.Char8 as C8 ... input <- C8.getLine C8.putStr $ result input ---------- But I have always WA#1. At my PC (Linux) I have right answers. then i tried: input' <- C8.getLine let input = if (C8.index input' (-1 + C8.length input')) == '\r' then C8.init input' else input' -------- So, i removed last character '\r' from line if it exists. And after this my code was accepted! Could you tell me what is test N9? |
|