# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
155157 | 2019-09-26T17:18:55 Z | phillip | Igra (COCI17_igra) | C++14 | 3 ms | 376 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Incorrect | 2 ms | 376 KB | Output isn't correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Incorrect | 2 ms | 376 KB | Output isn't correct |
6 | Incorrect | 2 ms | 376 KB | Output isn't correct |
7 | Incorrect | 2 ms | 256 KB | Output isn't correct |
8 | Incorrect | 2 ms | 376 KB | Output isn't correct |
9 | Incorrect | 3 ms | 376 KB | Output isn't correct |
10 | Incorrect | 3 ms | 376 KB | Output isn't correct |