# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
499083 | LouayFarah | Igra (COCI17_igra) | C++14 | 48 ms | 476 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"
using namespace std;
#define endl "\n"
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const long long MOD = 1e9+7;
const long long INF = 1e18;
int nx[4] = {0, 0, -1, 1};
int ny[4] = {1, -1, 0, 0};
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n;
cin >> n;
string a, b;
cin >> a >> b;
sort(a.begin(), a.end());
vector<bool> visited(n, false);
string res1 = "";
string res2 = "";
string res3 = "";
string res4 = "";
for(int i = 0; i<n; i++)
{
for(int j = 0; j<n; j++)
{
if(visited[j])
continue;
if(a[j]!=b[i])
{
visited[j] = true;
res1.pb(a[j]);
break;
}
}
}
visited.assign(n, false);
for(int i = 0; i<n; i++)
{
for(int j = n-1; j>=0; j--)
{
if(visited[j])
continue;
if(a[j]!=b[i])
{
visited[j] = true;
res2.pb(a[j]);
break;
}
}
}
visited.assign(n, false);
for(int i = n-1; i>=0; i--)
{
for(int j = 0; j<n; j++)
{
if(visited[j])
continue;
if(a[j]!=b[i])
{
visited[j] = true;
res3.pb(a[j]);
break;
}
}
}
reverse(res3.begin(), res3.end());
visited.assign(n, false);
for(int i = n-1; i>=0; i--)
{
for(int j = n-1; j>=0; j--)
{
if(visited[j])
continue;
if(a[j]!=b[i])
{
visited[j] = true;
res4.pb(a[j]);
break;
}
}
}
reverse(res4.begin(), res4.end());
vector<string> res;
if(int(res1.size())==n)
res.pb(res1);
if(int(res2.size())==n)
res.pb(res2);
if(int(res3.size())==n)
res.pb(res3);
if(int(res4.size())==n)
res.pb(res4);
sort(res.begin(), res.end());
cout << res[0] << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |