Submission #40889

#TimeUsernameProblemLanguageResultExecution timeMemory
40889XmtosXIgra (COCI17_igra)C++14
10 / 100
94 ms728 KiB
#include <bits/stdc++.h> using namespace std; int n; string s1,s2; int main() { cin >>n>>s1>>s2; for (int i=0;i<n;i++) { for (int j=i+1;j<n;j++) { if (s1[i]!=s2[j]&&s1[j]!=s2[i]) { if (s1[i]==s2[i]) swap(s1[i],s1[j]); else if (s1[i]>s1[j]) swap(s1[i],s1[j]); } } } int pos=n-1; if (s1[n-1]==s2[n-1]) { for (int i=n-1;i>=0;i--) { int j=n-1; if (s1[i]!=s2[j]&&s1[j]!=s2[i]) { if (s1[i]>s1[j]) pos=i; else if (pos==n-1) pos=i; } } } swap(s1[n-1],s1[pos]); cout <<s1; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...