Show all threads Hide all threads Show all messages Hide all messages |
please help !! !! !! !! !! | I_want_to_be_The_Best | 1354. Palindrome. Again Palindrome | 13 May 2005 22:20 | 4 |
why my program not work ?? #include<iostream.h> //#include<conio.h> // char s[10001]; char s2[10001]; char s3[20002]; int l; //------------------------------------- int L(void); int Pal(int i); int First(void); //------------------------------------- void main(void) { //clrscr(); // int x,i; // cin>>s; // l=L(); x=First(); // //printf("%s",s); for(i=x-1;i>=0;i--) s2[x-1-i]=s[i]; s2[x]=0; for(i=0;i<x;i++) s[l+i]=s2[i]; s[l+x]=0; for(i=0;s[i];i++) s3[i]=s[i]; cout<<s3; // //getch(); } //------------------------------------- int L(void) { int r; // for(r=0;s[r];r++); // return(r); } // int First(void) { int r,flag=1; // r=1; while((flag)&&(r<l)) if(Pal(r)) flag=0; else r++; // return(r); } // int Pal(int i) { int r; // while((r)&&( r<((l+i)/2) )) if(s[r]==s[l-r+i-1]) r++; else r=0; // return(r); } i not see error !! !! On test: vxabba your program outputs vxabbaabbaxv, but right answer is vxabbaxv thanks for the test! i fixed the bug, but I still WA#4 |
WA on test 7 | Alexandru Popa | 1354. Palindrome. Again Palindrome | 12 Apr 2005 23:27 | 3 |
Why ? My program looks ok ! Any trick or special test case ? Thank you ! |
Wrong answer test(4) Help me+++++ give some test+++++ | Виктор Крупко | 1354. Palindrome. Again Palindrome | 12 Apr 2005 23:16 | 6 |
program de; var s:string; i,j,l,z,ost:integer; q:boolean; mas:array[1..20000] of char; begin readln(s); l:=length(s); for i:=1 to l do mas[i]:=s[i]; if l=1 then writeln(mas[i]) else if (l=2) and (mas[1]=mas[2]) then writeln(mas[1],'',mas[2]) else begin q:=true; for i:=1 to l div 2 do if mas[i]<>mas[l-i+1] then q:=false; if q then begin for i:=1 to l do write(mas[i]); end else begin for i:=l div 2 to l do begin q:=true; z:=0; ost:=0; while z+i<>l do begin inc(z); if mas[i-z+1]<>mas[i+z] then q:=false; end; if q then ost:=1; z:=0; if q<>true then begin q:=true; while z+i<>l do begin inc(z); if mas[i-z]<>mas[i+z] then q:=false; end; end; if q then begin for j:=1 to i do write(mas[j]); if i<>l then i:=i+ost; for j:=i-1 downto 1 do write(mas[j]); break; end; end; end; end; readln; end. Da ti idiot, blia!! var s1,s2:array[1..10000] of char; i,j,k,n,g,h:integer; noans:boolean; ch : char; begin read(ch); while ch in ['a'..'z','A'..'Z','0'..'9'] do begin inc(i); s1[i]:=ch; read(ch); end; n:=i; if n=0 then writeln(' '); if n=1 then writeln(s1[1],s1[1]); if n>1 then begin for j:=2 to n do begin noans:=true; h:=n; if s1[j]=s1[n] then begin noans:=false; for k:=j to ((n-j) div 2)+j-1 do begin if s1[k]=s1[h] then h:=h-1 else begin noans:=true; break; end; end; end; if not noans then begin for i:=1 to n do write(s1[i]); for g:=(j-1) downto 1 do write(s1[g]); halt; end; end; end; end. butcherFac you xitro viebannii 4to-li. Tebe cpokoino ne givetcia. Tebia B realnoi gizni 4asto obigaut. Po4emy B tebe stolko zlosti??????? |
Why WA. Need help | ShipilinSergey | 1354. Palindrome. Again Palindrome | 3 Apr 2005 03:45 | 2 |
var S:string; i,j:integer; A,B:longint; begin readln(s); A:=0; B:=0; j:=length(s) div 2; if odd(length(s)) then inc(j); for i:=1 to j do begin A:=A+Ord(s[i]); end; for i:=length(s) downto j do begin B:=B+Ord(s[i]); end; if a<>b then begin for i:=length(s)-1 downto 1 do begin s:=s+s[i]; end; writeln(s); end else Writeln(s); end. |
Why WA 4????????????? | Black Raven | 1354. Palindrome. Again Palindrome | 31 Mar 2005 02:28 | 2 |
I can't understand what's wrong with my code: #include <iostream> #include <string> using namespace std; bool isPalindrom(string str, unsigned n){ unsigned num1=n, num2=str.size()-n-1, num; if(num1>num2) num=num2; else num=num1; for(unsigned a=0; a<=num; a++) if(str[n-a]!=str[n+a]) return false; return true; } int main(){ string s1; unsigned x; cin>>s1; if(s1.size()==1){ cout<<s1; return 0; } string str; for(unsigned a=s1.size()/2; a<s1.size(); a++) if(isPalindrom(s1, a)){ x=a; for(unsigned a=0; a<x; a++) str+=s1[a]; str+=s1[x]; for(int b=x-1; b>=0; b--) str+=s1[b]; if(s1 < str){ cout<<str<<endl; return 0; } str.erase(); } return 0; } 1) Please, delete your code 2) Read task more carefully: "You are to find a NONEMPTY word S2 of the minimal length that S1S2 - is a palindrome." I think your solution will fail on testcase like "SOS" |
Why ML 22?? | Putilin Alexander | 1354. Palindrome. Again Palindrome | 30 Mar 2005 07:29 | 6 |
I cannot understand, why I have Memory Limit on test 22. I have only 2 strings and 6 Longints. Anybody help me! Don't use ansistring. Use array of char and KMP-algorithm. Why KMP? Shteiner Sergei 27 Mar 2005 21:25 |
HELP! | mahbubul | 1354. Palindrome. Again Palindrome | 28 Mar 2005 18:27 | 2 |
HELP! mahbubul 28 Mar 2005 18:08 I am getting WA with my bruteforce code. I can't understand why! Can some1 provide some cases? See! How fool I am! I have not tested my code with length 1! Huf! for that i had to loose 5 submissions! |