# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
490327 |
2021-11-27T06:38:37 Z |
niloyroot |
Igra (COCI17_igra) |
C++14 |
|
7 ms |
332 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pl = pair<ll,ll>;
#define pb push_back
#define form(m,it) for(auto it=m.begin(); it!=m.end(); it++)
#define forp(i,a,b) for(ll i=a; i<=b; i++)
#define forn(i,a,b) for(ll i=a; i>=b; i--)
#define newl '\n'
#define ff first
#define ss second
const ll mod = 1000000007;
void solve(){
ll n; cin>>n;
string a,b; cin>>a>>b;
sort(a.begin(), a.end());
char c,ind;
forp(i,0,n-1){
if(a[i]==b[i]){
c='z'; ind=-1;
forp(j,i+1,n-1){
if(a[j]!=a[i] && b[j]!=a[i]){
if(c=='z'){
c=a[j];
ind=j;
} else if(a[j]<c){
ind=j; break;
}
}
}
if(ind==-1){
forn(j,i-1,0){
if(a[j]!=a[i] && b[j]!=a[i]){
ind=j; break;
}
}
}
swap(a[i],a[ind]);
}
}
cout<<a<<newl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t=1; //cin>>t;
while(t--)solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
9 |
Incorrect |
6 ms |
332 KB |
Output isn't correct |
10 |
Incorrect |
7 ms |
332 KB |
Output isn't correct |