Submission #155157

#TimeUsernameProblemLanguageResultExecution timeMemory
155157phillipIgra (COCI17_igra)C++14
0 / 100
3 ms376 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; int dp[5009][3]; int n,a[5009]; int x[5009]; string s; int main() { cin>>n>>s; for(int i=0;i<n;i++)x[s[i]-'a']++; cin>>s; for(int i=n-1;i>=0;i--) { for(int j=0;j<3;j++)dp[i][j]=dp[i-1][j]; dp[i][s[i]-'a']++; } for(int i=0;i<n;i++) { int num=s[i]-'a'; if(i==n-1) { for(int j=0;j<3;j++) { if(x[j])a[i]=j; } break; } for(int j=0;j<3;j++) { if(j==num)continue; int k; if(num==0) { if(j==1)k=2; else k=1; } if(num==1) { if(j==2)k=0; else k=2; } if(num==2) { if(j==1)k=0; else k=1; } if(x[num]+x[j]>dp[i+1][k]) { x[j]--; a[i]=j; break; } } //for(int i=0;i<3;i++)cout<<x[i]<<" ";cout<<"\n"; } for(int i=0;i<n;i++)cout<<char('a'+a[i]); } /* 6 abcaaa aabbbb */

Compilation message (stderr)

igra.cpp: In function 'int main()':
igra.cpp:49:37: warning: 'k' may be used uninitialized in this function [-Wmaybe-uninitialized]
             if(x[num]+x[j]>dp[i+1][k])
                            ~~~~~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...