/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 24ms 552.0 KiB
#3 Wrong Answer 25ms 540.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;
    
    
    
    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:41:53
Judged At
2024-12-07 10:41:53
Judged By
Score
1
Total Time
25ms
Peak Memory
552.0 KiB