/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 332.0 KiB
#2 Wrong Answer 4ms 584.0 KiB
#3 Wrong Answer 4ms 784.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;

#define endl "\n"
#define trace(x) cout << #x << ": " << x << endl
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        string s, t;
        cin >> s >> t;
        bool ok = true;
        for(int i = 0; i < n - 1; i++)
        {
            if(s[i] > s[i + 1])
            {
                if(s[i + 1] >= t[i]) swap(s[i], t[i]);
            }
        }
        if(!ok)
        {
            for(int i = 0; i < n - 1; i++)
            {
                if(t[i] > t[i + 1])
                {
                    if(t[i + 1] < s[i]) swap(s[i], t[i]);
                }
            }
        }
        if(is_sorted(s.begin(), s.end()) or is_sorted(t.begin(), t.end()))
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1117 String Sorted
Contest
LU IUJPC : Sylhet Division 2024, Mock Round
Language
C++17 (G++ 13.2.0)
Submit At
2024-12-07 11:17:32
Judged At
2024-12-07 11:17:32
Judged By
Score
1
Total Time
4ms
Peak Memory
784.0 KiB