# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
40889 | XmtosX | Igra (COCI17_igra) | C++14 | 94 ms | 728 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;
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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |