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;
cin>>a>>b;
c=a;
d=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;i++){
if(a[i]!=c[i]){
if(c[i]<b[i]){
f=1;
break;
}
}
}
if(f==1){
for(i=0;i<n;i++){
if(b[i]!=d[i]){
if(a[i]>d[i]){
cnt=1;
break;
}
}
}if(cnt==1){
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 10:29:34
- Judged At
- 2024-12-07 10:29:34
- Judged By
- Score
- 1
- Total Time
- 18ms
- Peak Memory
- 584.0 KiB