/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 516.0 KiB
#2 Accepted 6ms 596.0 KiB
#3 Accepted 5ms 604.0 KiB
#4 Accepted 6ms 588.0 KiB
#5 Accepted 3ms 328.0 KiB
#6 Accepted 3ms 576.0 KiB
#7 Accepted 3ms 592.0 KiB
#8 Accepted 4ms 840.0 KiB
#9 Accepted 3ms 736.0 KiB
#10 Accepted 4ms 576.0 KiB

Code

#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define endl '\n'
#define Endl '\n'

using namespace std;

const int N = 2e5 + 5;
int tc, n, m, a[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); // cout.tie(0);
    cin >> tc;
    while (tc--) {
        string x, y;
        cin >> n >> x >> y;
        bool hasAns = true;
        char lastChar = 'a';
        for (int i = 0; i < n; i++) {
            int minChar = min(x[i], y[i]);
            int maxChar = max(x[i], y[i]);
            if (minChar >= lastChar) {
                lastChar = minChar;
            } else if (maxChar >= lastChar) {
                lastChar = maxChar;
            } else {
                hasAns = false;
                break;
            }
        }
        cout << (hasAns ? "Yes" : "No") << endl;
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1117 String Sorted
Contest
Lockout contest round-1 ( Mazharul Islam vs Thakur Emon)
Language
C++17 (G++ 13.2.0)
Submit At
2024-11-04 17:03:43
Judged At
2024-11-11 02:33:45
Judged By
Score
100
Total Time
6ms
Peak Memory
840.0 KiB