# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
203960 | awlintqaa | Igra (COCI17_igra) | C++14 | 6 ms | 380 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.
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 200
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef short int si;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod=1e9+7;
const ll inf= 4e18;
const ld pai=acos(-1);
int n ;
string s1,s2;
int NUM [3], num [3];
int RET [3], ret [3];
int check () {
for ( int i =0 ;i < 3 ;i ++ ) {
int crnt =0 ;
for ( int j =0 ;j < 3 ;j ++ ){
if ( i == j ) C;
crnt += num[j];
}
if ( NUM [i] > crnt ) return 0;
}
return 1 ;
}
int main(){
cin >> n ;
cin >> s1 >> s2;
for ( int i =0 ;i < s1.size() ;i ++ ){
num [s1[i]-'a'] ++ ;
}
for ( int i =0; i < s2.size() ;i ++ ){
NUM [s2[i]-'a'] ++ ;
}
string ans = "" ;
for ( int i =0 ;i < n ;i++ ){
int z = 0 ;
for ( int j =0 ;j < 3 ;j ++ ){
if ( s2 [i]-'a' == j || z )C;
NUM [ s2[i] - 'a' ] --;
num [ j ]--;
if ( check() ) {
z=1;
ans += (char) (j+'a');
}
NUM [s2[i] - 'a' ] ++;
num [j] ++;
}
NUM [s2[i]-'a'] -- ;
num [ ans [i] -'a' ] --;
}
cout << ans << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |