Submission #499083

#TimeUsernameProblemLanguageResultExecution timeMemory
499083LouayFarahIgra (COCI17_igra)C++14
20 / 100
48 ms476 KiB
#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 timeMemoryGrader output
Fetching results...