/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 17ms 560.0 KiB
#3 Accepted 18ms 556.0 KiB
#4 Accepted 20ms 556.0 KiB
#5 Accepted 7ms 540.0 KiB
#6 Accepted 6ms 584.0 KiB
#7 Accepted 6ms 540.0 KiB
#8 Accepted 6ms 932.0 KiB
#9 Accepted 6ms 668.0 KiB
#10 Accepted 6ms 796.0 KiB

Code

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

#define int         long long






void solve() {
    int n;          cin >> n;

    string s, t;        cin >> s >> t;


    bool ok = 1;
    char pre = min(s[0], t[0]);

    // cerr << pre << '\n';

    for (int i = 1; i < n; i++) {
        char curMin= min(s[i], t[i]);
        char curMax = max(s[i], t[i]);

        // cerr << curMax << ' ' << curMin << ' ' << pre << '\n';

        if (curMin >= pre) {
            pre = curMin;
            continue;
        }else if (curMax >= pre) {
            pre = curMax;
            continue;
        }

        ok = 0;
    }

    
    cout << ((ok) ? "Yes\n" : "No\n");
}



signed main() {
    int tt;     cin >> tt;

    while (tt--) 
        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:25:41
Judged At
2024-12-07 10:25:41
Judged By
Score
100
Total Time
20ms
Peak Memory
932.0 KiB