# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
155144 | phillip | Igra (COCI17_igra) | C++14 | 3 ms | 504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,aa,bb,cc;
string s;
int dp[21][21][21][21];
void bt(int i,int a,int b,int c,string x)
{
if(dp[i][a][b][c])return;
if(a==0&&b==0&&c==0)
{
cout<<x;
exit(0);
}
if(s[i]!='a'&&a)
{
bt(i+1,a-1,b,c,x+'a');
}
if(s[i]!='b'&&b)
{
bt(i+1,a,b-1,c,x+'b');
}
if(s[i]!='c'&&c)
{
bt(i+1,a,b,c-1,x+'c');
}
dp[i][a][b][c]=1;
}
int main()
{
cin>>n>>s;
for(int i=0;i<n;i++)
{
if(s[i]=='a')aa++;
else if(s[i]=='b')bb++;
else cc++;
}
cin>>s;
bt(0,aa,bb,cc,"");
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |