/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 556.0 KiB
#2 Accepted 4ms 840.0 KiB
#3 Accepted 3ms 796.0 KiB
#4 Accepted 4ms 540.0 KiB
#5 Accepted 2ms 540.0 KiB
#6 Accepted 2ms 540.0 KiB
#7 Accepted 2ms 796.0 KiB
#8 Accepted 2ms 796.0 KiB
#9 Accepted 2ms 924.0 KiB
#10 Accepted 2ms 1.004 MiB

Code

#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define print(v) for(auto data : v) cout << data << " "; cout << endl;
using namespace std;
void solve()
{
    int n; string a, b; cin >> n >> a >> b;
    string x;
    for(int i = 0; i<n; i++)
    {
        x += min(a[i], b[i]);
    }

    for(int i = 1; i<n; i++)
    {
        if(x[i-1] > x[i]){
            if(x[i-1] > max(a[i],b[i])){
                cout << "No\n";
                return;
            }else{
                x[i] = max(a[i],b[i]);
            }
        }

    }
    cout << "Yes\n";
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int t; cin >> t;
    //int t = 1;
    while(t--) solve();

    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 10:32:22
Judged At
2024-12-07 10:32:22
Judged By
Score
100
Total Time
4ms
Peak Memory
1.004 MiB