Показать все ветки Спрятать все ветки Показать все сообщения Спрятать все сообщения |
CE what is my code problem ? | Aliaga Shirinov | 1354. Палиндром. Он же палиндром | 26 ноя 2013 13:58 | 1 |
#include <iostream> #include <vector> #include <math.h> #include <cstdio> #include <algorithm> #include <string> using namespace std; int main() { long long m,h = 0,i,t,l,n,f; string a,s; cin >> a; s = a; for(i = a.length()-1 ;i >= 0 ;i--) s[h] = a[i],h++; f = s.length()-2; i = 0; n = f; while(n >= 1 && m != 0) { t = n; m = 0; while(i <= n - (n / 2) - 1) { if(s[i] != s[t]) { m = 1; break; } i++; t--; } n--; i = 0; } if(m == 0) n++; for(i = 0 ;i < a.length() ;i++) cout << a[i]; for(i = n + 1 ;i < s.length() ;i++) cout << s[i]; cout << endl; return 0; } |
!!!!!help!!!!! WA #20 | STAVASD | 1354. Палиндром. Он же палиндром | 17 мар 2013 02:54 | 4 |
Could anyone tell me test #20? Try: No = NoN Noo = NooN Nooo = NoooN Also, make sure you cater for: t = tt tt = ttt ttt = tttt (can't just add an empty string) Thanks, this helped me!! :) Edited by author 17.03.2013 03:17 |
WA #30 | Frustra Conatus | 1354. Палиндром. Он же палиндром | 14 мар 2013 08:08 | 2 |
WA #30 Frustra Conatus 11 сен 2011 20:55 Anyone had the same problem? please give a hint!! This helped me: noooooMmMooo = noooooMmMooooon (mine was giving: noooooMmMoooMmMooooon) |
Help TL #22 | Varun Sharma | 1354. Палиндром. Он же палиндром | 11 мар 2012 18:36 | 2 |
Hi, I am using a very naive algorithm to solve this problem and that's getting TL on later test cases. Can someone tell the name of the efficient algorithm which we can use for this problem ? Thanks If you are using Java then use StringBuilder instead of Strings. |
No tests with >256 characters? | PrankMaN | 1354. Палиндром. Он же палиндром | 20 янв 2012 15:19 | 2 |
I used pascal strings and got AC. From description: "Strings can be longer than 255 characters.". So tests can content strings with length more than 256 characters. |
This is problem 4103 / EPALIN on SPOJ | Nic Roets | 1354. Палиндром. Он же палиндром | 26 окт 2011 05:58 | 2 |
But the test data on SPOJ is wrong. Not really, you are allowed to add zero characters in spoj task, but here it's not allowed. |
O(n), hashing!!! | hoan | 1354. Палиндром. Он же палиндром | 19 авг 2011 17:16 | 3 |
O(n^2), brute-forcing!!! =) solved by hashing too, so this problem could be expanded to n ~ 10^6 |
Hint | MadMag | 1354. Палиндром. Он же палиндром | 12 авг 2011 09:45 | 1 |
Hint MadMag 12 авг 2011 09:45 Just find the biggest polindrom, which ends in the end of s1 and so s2 is a part at the beginnig of the s1 (which is not a part of a palindrom) written backwards. |
WA5 | ISDemidoff | 1354. Палиндром. Он же палиндром | 4 авг 2011 16:21 | 2 |
WA5 ISDemidoff 3 авг 2011 10:31 Can sb send test 5 and ans? |
how did use KMP algo to structure palindrom? | lian lian | 1354. Палиндром. Он же палиндром | 19 июл 2011 16:27 | 3 |
I think the question for some day, but I can`t solve.... please give hint..... Edited by author 26.08.2008 05:22 First you can calculate prefix array for reversed word. And then run algorithm that finds occurence or reversed word in S1, but stop it when forward and backard iterators meet each other. Ignore requirement S2 to be nonempty for now, and take it into account when algorithm will be almost ready Consider A - original string, B - reversed. Build preffix array for B, run KMP (search for B in A) with slight fix. In usual KMP you find a number of letters, that coincide in strings, and want it to be equal to size of B. In this problem you just remember this number (let it be Q). So after KMP you know, that last Q letters are a palindrome. The only moment is what needs to be done, if Q == size of A. Then you should undo last KMP step (Q = P[Q-1]) and find previous palindrome. |
For everyone who get WA$4 and WA#8 | Ayhan Aliyev [BOTL] | 1354. Палиндром. Он же палиндром | 15 июл 2011 01:05 | 6 |
These tests helped me very much. I hope it will help you. 2101221012 and answer is 210122101221012 (in test#4) 122212221 answer is 1222122212221 (in test#8) Thanks, I found mistake and got AC. top push! Edited by author 29.11.2007 00:07 I think you should use this sample aaaaaa answer aaaaaaa Thanks ! I have AC ! Thank you very much for your suggest ! My AC code : #include "iostream.h" #include "string.h" char s[20000]={"AbabaAab"}; int equal(int index1,int index2) {...} int main() { int a,b; cin.getline(s,10002); int l = strlen(s); for(a=1;a<l;a++) if(equal(a,l-1)) break; for(b=1;b<=a;b++) s[l+b-1]=s[a-b]; s[l+b-1]=0; cout<<s; return 0; } for 122212221 i have correct answer, but WA#8, what the problem? This is weird. It tells me WA#4 but in my PC I get the right 210122101221012. Has the test changed? |
WHAT IS WA#21 | zhyu | 1354. Палиндром. Он же палиндром | 14 апр 2011 17:45 | 1 |
Help plz! I used hash,and got a WA at #21! |
WA24 | TheDreamCatcher | 1354. Палиндром. Он же палиндром | 30 ноя 2010 18:53 | 1 |
WA24 TheDreamCatcher 30 ноя 2010 18:53 I used in my program char a[10000]; cin>>a; after I used char a[10001]; cin>>a; and got AC |
Help, please, I have AC. | Blum | 1354. Палиндром. Он же палиндром | 16 июл 2010 15:46 | 5 |
I've got AC constructing suffix tree (mcc algo). Now, who also has O(N) solution simplier than mine, please tell me your idea. And is O(N*N) anough to get AC? Thanks. Oh, yes. How stupid I was. Thanks a lot. Now I have AC with kmp) I've got AC constructing suffix tree (mcc algo). Now, who also has O(N) solution simplier than mine, please tell me your idea. And is O(N*N) anough to get AC? Thanks. yes. It is a little strange, but O(n^2) really gets AC How to solve this problem using KMP? Somthing with prefix function or what? Help me pls, 'cause I solved this only with O(n^2). |
WA #29 | Connector | 1354. Палиндром. Он же палиндром | 18 июн 2010 21:54 | 1 |
WA #29 Connector 18 июн 2010 21:54 Check your vars for type overflow (if KMP check the type of array of pr) |
No subject | Vladislav Ivanishin | 1354. Палиндром. Он же палиндром | 2 июл 2009 02:32 | 1 |
Edited by author 02.07.2009 21:24 |
Weak limitations | partisan | 1354. Палиндром. Он же палиндром | 13 июн 2009 16:32 | 2 |
A limitation of 10000 is weak. My "stupid" O(n^2) PASCAL solution gets AC in 0.078 sec. It works very fast even on its worth test: aaaa....aaaab (9999 letters 'a') where it makes 9999 iterations with = and Delete() with strings of length 10000. But actually I don't know how to change this. If just increase limitation, even correct solutions gets WA... Maybe it is actual to make version 2 of problem, with limitation in 100000 or 250000. |
Its very very easy!!! | RASTA | 1354. Палиндром. Он же палиндром | 19 мар 2009 13:33 | 1 |
my idea for solution k := 2; n := length(s); s1 := s[1]; while true do begin i := 0; while (n - i >= k + i) and (s[k + i] = s[n - i]) do inc(i); if n - i <= k + i then begin write(s + s1); halt; end; s1 := s[k] + s1; inc(k); end; |
what is in the test #4??? | gigimarga | 1354. Палиндром. Он же палиндром | 4 янв 2009 19:56 | 6 |
excuse my english first. i tried my program on a lot of examples of mine and it's ok. but i got for 10 times WA on the test #4...why? can anybody tell me what's about or give me some hint for this problem? thx all if s1 is palindrome 。。 s2 cat't be a empty sequence! :D
Tam mnogo otvetov Na ety temy Sidi 4itai!!!! Try this test abbaa Answer is abbaabba - center of palindrome can be between chars! Edited by author 04.01.2009 20:00 Edited by author 04.01.2009 19:59 |
Palindome. Again Palindome | Buni_Real | 1354. Палиндром. Он же палиндром | 9 окт 2008 20:39 | 1 |
WA#4 program Palindome. Again Palindome; 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. THANKS ALL RIGHT |