/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 5ms 540.0 KiB
#3 Wrong Answer 5ms 540.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'

void solve() 
{
    ll n; cin >> n;
    string s,p; cin >> s >> p;
    string cs = p, cp = s;

    for (ll i = 1; i < n; i++) {
        if (s[i] < s[i - 1] || cs[i] > s[i - 1] && cs[i] < s[i]) {
            swap(s[i], cs[i]);
        }

    }
    for (ll i = 1; i < n; i++) {
        if (p[i] < p[i - 1] || cp[i] > p[i - 1] && cp[i] < p[i]) {
            swap(p[i], cp[i]);
        }

    }

    bool check1 = 1, check2 = 1;


    for (ll i = 1; i < n; i++) {
        if (s[i] < s[i - 1]) {
            check1 = 0;
        }
    }
    for (ll i = 1; i < n; i++) {
        if (p[i] < p[i - 1]) {
            check2 = 0;
        }
    }

    if (check1 || check2) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }

    //cout << s << " " << p << endl;






}

int main() 
{

    ios::sync_with_stdio(false); cin.tie(0);
    //ll t = 1;
    ll t; cin >> t;
    while(t--) {
        solve();
    }


}

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 10:29:59
Judged At
2024-12-07 10:29:59
Judged By
Score
1
Total Time
5ms
Peak Memory
540.0 KiB