Wrong Answer
Code
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
while(t--){
long long n,i,j,k,cnt=0,f=0,ans=0;
cin>>n;
string a,b,c,d,e,g;
cin>>a>>b;
c=a;
d=b;
e=a;
g=b;
sort(c.begin(),c.end());
sort(d.begin(),d.end());
if(a==c || b==d){
cout<<"Yes"<<"\n";
}else{
for(i=0;i<n-1;i++){
if(a[i]>a[i+1]){
a[i]=b[i];
}
}
if(!is_sorted(g.begin(),g.end())){
for(i=0;i<n-1;i++){
if(b[i]>b[i+1]){
b[i]=e[i];
}
}
if(!is_sorted(b.begin(),b.end())){
cout<<"No"<<"\n";
}else{
cout<<"Yes"<<"\n";
}
}else{
cout<<"Yes"<<"\n";
}
}
}
}
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:20:30
- Judged At
- 2024-12-07 11:20:30
- Judged By
- Score
- 0
- Total Time
- 19ms
- Peak Memory
- 560.0 KiB