/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 26ms 556.0 KiB
#3 Wrong Answer 26ms 548.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 A= a;
    string B= b;
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    if(a==A or B==b){
        cout << "Yes\n";
        return;
    }
    bool chk=false;
    for(int i=0; i<a.size(); i++){
        for(int j=i; j<i+1; j++){
            if(!chk){
                swap(a[i], b[j]);
                string a1= a;
                string b1= b;
                sort(a1.begin(), a1.end());
                sort(b1.begin(), b1.end());
                if(a==a1 || b==b1){
                    chk=true;
                    break;
                }else{
                    swap(a[i], b[j]);
                }
            }
        }
     }
     if(chk){
        cout << "Yes\n";
     }else{
        cout << "No\n";
     }
}

signed main(){
    ios_base::sync_with_stdio;
    cin.tie();
    cout.tie();
    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:46:36
Judged At
2024-12-07 10:46:36
Judged By
Score
1
Total Time
26ms
Peak Memory
556.0 KiB