/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 13ms 588.0 KiB
#3 Wrong Answer 13ms 592.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PI acos(-1.0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<pii>
#define rev_str(str) reverse(str.begin(),str.end());
#define print(v) for(auto i:v) cout<<i<<" ";cout<<endl;
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(ll i =a ;i<b;i++)
#define per(i,b,a) for(ll i=b;i>=a;i--)
bool sortByValue(const pair<int,int>& a,const pair<int,int>& b){
    return a.second > b.second;
}

void solve(){
    ll n;
    cin >> n;
    string a, b;
    cin >> a >> b;
    string x, y;
    x = b, y = a;

    for (int i = 0; i < n - 1; i++){
        // first string
        if (a[i] < a[i + 1]){
            if (a[i] > x[i]){
                swap(a[i], x[i]);
            }
        }
        else{
            swap(a[i], x[i]);
        }

        //second string
        if (b[i] < b[i + 1]){
            if (b[i] > y[i]){
                swap(b[i], y[i]);
            }
        }
        else{
            swap(b[i], y[i]);
        }   
    }
    //cout << a << ' ' << b << endl;
    if (is_sorted(a.begin(), a.end()) || is_sorted(b.begin(), b.end())){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;

    }
}

int main(){
    fast;
    ll t=1;cin>>t;
    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 11:44:06
Judged At
2024-12-07 11:44:06
Judged By
Score
1
Total Time
13ms
Peak Memory
592.0 KiB