# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
486103 | perchuts | Igra (COCI17_igra) | C++17 | 1 ms | 332 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 maxn (int)(1e5+51)
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii tuple<int,int,int>
#define inf (int)(2e9+1)
#define mod (int)(1e9+7)
using namespace std;
int n,q[3];
int main() {
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
string in,m,ans="";
cin>>n>>in>>m;
for(int i=0;i<n;i++)
q[in[i]-'a']++;
for(int i=0;i<n;i++){
int x,y,z;
if(m[i]=='a'){
x=0,y=1,z=2;
}else if(m[i]=='b'){
x=1,y=0,z=2;
}else{
x=2,y=0,z=1;
}
int ok=1;
if(!q[x]&&q[y]==1){
for(int j=1+i;j<n;j++){
if(m[j]==(char)(z+'a')){
ok=0;
q[z]--;ans+=(char)(z+'a');
break;
}
}
}
if(ok){
if(!q[y]){
q[z]--;ans+=(char)(z+'a');
}else{
q[y]--;ans+=(char)(y+'a');
}
}
}
cout<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |