Show all threads Hide all threads Show all messages Hide all messages |
Page 3 |
Wa19 | capitan.ARA.code | 1635. Mnemonics and Palindromes | 27 Oct 2022 10:09 | 1 |
Wa19 capitan.ARA.code 27 Oct 2022 10:09 bonnon Answer b onno n Edited by author 27.10.2022 10:18 Edited by author 27.10.2022 10:19 |
Page 2 |
solution | Anton | 1635. Mnemonics and Palindromes | 19 Nov 2021 02:17 | 1 |
might it is very complicated but i use hash and dp to solve this problem |
If you have MLE. | wiwi | 1635. Mnemonics and Palindromes | 22 Nov 2020 16:44 | 1 |
I had MLE on test 33. I just changed int to short and 1,0 to bool Sorry if this is too obvious Edited by author 22.11.2020 16:48 |
If you have WA20 | mikeweat | 1635. Mnemonics and Palindromes | 15 Aug 2018 21:17 | 1 |
Try this abacabadabacab. The problem is in hash. Answer is : a bacabadabacab Edited by author 15.08.2018 21:18 |
WA42? | shota | 1635. Mnemonics and Palindromes | 30 Sep 2017 16:48 | 2 |
WA42? shota 30 Sep 2017 12:39 Re: WA42? Mahilewets Nikita [BSUIR] 30 Sep 2017 16:48 It is something unique I have had WA20, WA23, TLE32, MLE56 But never WA42 |
wa24 help | Grandmaster | 1635. Mnemonics and Palindromes | 5 Feb 2017 04:22 | 1 |
nvm accepted Edited by author 05.02.2017 04:33 |
WA#19 | Maksim | 1635. Mnemonics and Palindromes | 24 Feb 2016 16:20 | 1 |
WA#19 Maksim 24 Feb 2016 16:20 pls help Edited by author 24.02.2016 16:20 |
If WA #5 | Accelarator | 1635. Mnemonics and Palindromes | 3 Dec 2015 08:18 | 1 |
try this: aaaba is 2 aa aba not 3 aaa b a |
WA 12 | buea | 1635. Mnemonics and Palindromes | 23 Oct 2015 07:18 | 2 |
WA 12 buea 23 Oct 2015 06:59 Stuck at test case #12 Per reply in 2008, someone suggested testing with axayaaxa I don't know whether this is the real #12. But I tried anyway. My program answers a x aya axa And another possible answer is axa y a axa Both with 4 palindromes. Question says output any is correct. Suggestion? Thanks in advance! I spotted a bug. Will fix it first and try again. |
WA #59 | Nik | 1635. Mnemonics and Palindromes | 24 Mar 2015 20:32 | 1 |
|
No subject | CU_PROBABILITY | 1635. Mnemonics and Palindromes | 22 Aug 2018 12:25 | 2 |
I am getting wrong answer.Please give me some test case. My solution: #include<iostream> #include<string.h> #include<string> #include<stdlib.h> #include<stdio.h> #include<vector> #include<algorithm> using namespace std; string line; bool check(int s,int e) { string temp; for(int i=s; i<=e; i++) temp.push_back(line[i]); string temp2=temp; reverse(temp.begin(),temp.end()); if(temp==temp2) return true; return false; } int dp[4005][4005]; int palindrome(int s,int e) { if(s>=e) return 0; if(dp[s][e]!=-1) return dp[s][e]; int ans=(1<<30); for(int i=s; i<e; i++) if(check(s,i)) { ans=min(ans,1+palindrome(i+1,e)); } return dp[s][e]=ans; } vector<string>anss; void print(int s,int e) { int b=palindrome(s,e); if(b==1) { string temp; for(int i=s; i<e; i++) temp.push_back(line[i]); anss.push_back(temp); return; } for(int i=s; i<e; i++) if(b==1+palindrome(i+1,e)) { string temp; for(int j=s;j<=i;j++) temp.push_back(line[j]); anss.push_back(temp); print(i+1,e); break; } } int main() { cin>>line; int len; len=line.size(); anss.clear(); memset(dp,-1,sizeof dp); cout<<palindrome(0,len)<<endl; print(0,len); len=anss.size(); for(int i=0;i<len-1;i++) cout<<anss[i]<<" "; cout<<anss[len-1]<<"\n"; } Ответ aper 22 Aug 2018 12:25 Ошибка где-то тут: string line; bool check(int s,int e) { string temp; for(int i=s; i<=e; i++) temp.push_back(line[i]); string temp2=temp; reverse(temp.begin(),temp.end()); if(temp==temp2) return true; return false; } int dp[4005][4005]; int palindrome(int s,int e) { if(s>=e) return 0; if(dp[s][e]!=-1) return dp[s][e]; int ans=(1<<30); for(int i=s; i<e; i++) if(check(s,i)) { ans=min(ans,1+palindrome(i+1,e)); } return dp[s][e]=ans; } vector<string>anss; void print(int s,int e) { int b=palindrome(s,e); if(b==1) { string temp; for(int i=s; i<e; i++) temp.push_back(line[i]); anss.push_back(temp); return; } for(int i=s; i<e; i++) if(b==1+palindrome(i+1,e)) { string temp; for(int j=s;j<=i;j++) temp.push_back(line[j]); anss.push_back(temp); print(i+1,e); break; } } int main() { cin>>line; int len; len=line.size(); anss.clear(); memset(dp,-1,sizeof dp); cout<<palindrome(0,len)<<endl; print(0,len); len=anss.size(); for(int i=0;i<len-1;i++) cout<<anss[i]<<" "; cout<<anss[len-1]<<"\n"; } Edited by author 22.08.2018 12:26 Edited by author 22.08.2018 12:26 |
WA #7 can anyone help plz? | Rahul Agarwal | 1635. Mnemonics and Palindromes | 3 Dec 2015 07:56 | 3 |
WA #7 can anyone help plz? using simple dp you are probably considering to get rid of palindromes as early as possible for example, consider the case "aabba" if you say it is 3 palindromes: "aa", "bb", and "a", then you are wrong, since it can be "a" and "abba" |
WA #1 | GongLiangqi | 1635. Mnemonics and Palindromes | 22 Nov 2015 19:34 | 5 |
WA #1 GongLiangqi 27 Mar 2013 18:15 Can you tell me why I always WA #1? Beacause I have tested all those samples in the board, and I pass them all... OK...I have got it...in Ural...in C...You must write like boolflag == 1...You can not write like boolflag,which works in my computer... aaaabaaa correct answer is 2 a aaabaaa your example is very good ! |
Why TLE??? | Accepted | 1635. Mnemonics and Palindromes | 24 Mar 2013 18:46 | 1 |
I test my code at my computer,I got a test which is filled by period string "abcde" and its length is 4000,and my program run only 0.25s. My computer is: Memory:3GB System:Windows XP CPU:1.66GHZ But I got tle at #32...Why??? Here is my code. var i,j,xx,ox,t,l:longint; s:ansistring; f,x:array [1..4010] of longint; o:array [0..4010] of boolean; function pdhw(l,r:longint):boolean; var i:longint; begin if l=r then exit(true); for i:=l to (l+r)>>1+1 do if s[i]<>s[r+l-i] then exit(false); exit(true); end; begin readln(s); l:=length(s); for i:=1 to l do begin f[i]:=maxlongint; if pdhw(1,i) then f[i]:=0 else for j:=1 to i-1 do if (f[i]>f[j]+1)and(pdhw(j+1,i)) then begin f[i]:=f[j]+1; x[i]:=j; end; end; writeln(f[l]+1); xx:=l; repeat ox:=xx; xx:=x[xx]; if ox=l then o[xx+1]:=true else o[xx+1]:=true; until xx=0; o[1]:=false; for i:=1 to length(s) do if o[i] then write(' ',s[i]) else write(s[i]); end. |
Is there linear time algorithm which solves the problem? | [SPb NRU ITMO] Niyaz Nigmatullin | 1635. Mnemonics and Palindromes | 7 Feb 2013 01:35 | 1 |
|
finally accepted | Evgeny | 1635. Mnemonics and Palindromes | 22 Nov 2015 20:37 | 4 |
maybe it will be useful (or at least interesting) for somebody. at first i tried to make simple DP with O(n^3). i tried in java (and i received TLE in 32th test). after that i tried to realize greed algorithm and understood that this idea is wrong (simple antigreed test is: "abzzbbbzza") aand finally i've made O(n^2) DP. little hint: try to precalc d[l][r]: d[l][r] = true, s[l..r] - palindrom d[l][r] = false, s[l..r] - not palindrom whats the ans for 'abzzbbbzza'? i didn't get it how it will become n^2 because for l=1 to l=n is one loop and for r=l to r=n is inside loop and for checking it is palindrome is another loop so i don't get how it will be n^2 can you please explain me i am very confused here please help me |
WHY WA #12!!!!!! | carl cruise | 1635. Mnemonics and Palindromes | 22 Oct 2012 13:13 | 1 |
who can tell me what #12 is? I don't know where my program is wrong.Thank you in advance. Edited by author 22.10.2012 13:22 |
Интересная задача | nobik | 1635. Mnemonics and Palindromes | 16 Jun 2012 00:09 | 1 |
A very interesting problem! Cut two successive speakers: A. To determine the palindrome at l to r - d [l] [r] = s [l] == s [r] && d [l +1] [r-1] == 1? A: 0; 0 if it is not a palindrome, a palindrome if. Lazy dynamic))) Two. To determine the optimal line break at the Palindromes: dp [i] = min (dp [i], dp [ij] +1); That's all!)) Very pleased with himself))) I should think of such problems))) Edited by author 16.06.2012 05:40 Edited by author 16.06.2012 05:42 |
WA#1... | YSYMYTH | 1635. Mnemonics and Palindromes | 18 Dec 2011 14:50 | 1 |
I got a AC program from others and compare the ANSWER-nothing is wrong. So the ADMIN I need the TEST#1 please! |
WA 19! Somebody, help me, please! | ONU_Antananarivu | 1635. Mnemonics and Palindromes | 19 Aug 2013 13:38 | 2 |
Edited by author 08.09.2011 17:57 Give me your code ! I also WA 19,but I find write wrong dp[i]>dp[j-1]+1 to dp[i]>dp[j]^…… |