/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 588.0 KiB
#2 Accepted 3ms 584.0 KiB
#3 Accepted 4ms 540.0 KiB
#4 Accepted 3ms 796.0 KiB
#5 Accepted 2ms 540.0 KiB
#6 Accepted 2ms 584.0 KiB
#7 Accepted 2ms 444.0 KiB
#8 Accepted 2ms 1.25 MiB
#9 Accepted 2ms 924.0 KiB
#10 Accepted 2ms 924.0 KiB

Code

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

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

    string a, b; cin >> a >> b;
    string c;
    c.push_back(min(a[0], b[0]));
    for(int i = 1; i < n; i++){
        if(a[i] >= c.back() && b[i] >= c.back()){
            c.push_back(min(a[i], b[i]));
        }
        else if(a[i] >= c.back()){
            c.push_back(a[i]);
        }
        else if(b[i] >= c.back()){
            c.push_back(b[i]);
        }
        else{
           cout << "No\n";
            return;
        }
    }
    cout << "Yes\n";

}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
	int 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:18:25
Judged At
2024-12-07 10:18:25
Judged By
Score
100
Total Time
4ms
Peak Memory
1.25 MiB