# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
81990 |
2018-10-28T10:39:55 Z |
Vasiljko |
Igra (COCI17_igra) |
C++14 |
|
3 ms |
652 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int n,a,b,c,cura,curb,curc;
string s,t;
vector<char>ans;
bool check(int fi,int se,int th){
if(fi+se>=curc&&fi+th>=curb&&se+th>=cura)return true;
return false;
}
void Set(int ind,char p,int &val){
ans[ind]=p;
val--;
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>n;
cin>>s>>t;
ans.resize(n);
for(int i=0;i<n;i++){
if(s[i]=='a')a++;
else if(s[i]=='b')b++;
else c++;
}
for(int i=0;i<n;i++){
if(t[i]=='a')cura++;
else if(t[i]=='b')curb++;
else curc++;
}
for(int i=0;i<n;i++){
if(t[i]=='a'){
cura--;
bool ok1=check(a,b-1,c);
bool ok2=check(a,b,c-1);
if(ok1&&ok2)Set(i,'b',b);
else{
if(ok1)Set(i,'b',b);
else Set(i,'c',c);
}
}else if(t[i]=='b'){
curb--;
bool ok1=check(a-1,b,c);
bool ok2=check(a,b,c-1);
if(ok1&&ok2)Set(i,'a',a);
else{
if(ok1)Set(i,'a',a);
else Set(i,'c',c);
}
}else{
curc--;
bool ok1=check(a-1,b,c);
bool ok2=check(a,b-1,c);
if(ok1&&ok2)Set(i,'a',a);
else{
if(ok1)Set(i,'a',a);
else Set(i,'b',b);
}
}
}
for(auto e:ans)cout<<e;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
564 KB |
Output is correct |
4 |
Incorrect |
2 ms |
564 KB |
Output isn't correct |
5 |
Incorrect |
2 ms |
564 KB |
Output isn't correct |
6 |
Incorrect |
2 ms |
652 KB |
Output isn't correct |
7 |
Incorrect |
2 ms |
652 KB |
Output isn't correct |
8 |
Incorrect |
2 ms |
652 KB |
Output isn't correct |
9 |
Incorrect |
2 ms |
652 KB |
Output isn't correct |
10 |
Incorrect |
2 ms |
652 KB |
Output isn't correct |