Wrong Answer
Code
#include <bits/stdc++.h>
using namespace std;
void error()
{
int n;
cin >> n;
string s, p,m="";
cin >> s >> p;
for(int i=0;i<n;i++){
if((s[i]<=p[i] and i==0)){
m+=s[i];
}
else if(p[i]<=s[i] and i==0){
m+=p[i];
// cout<<m[i];
}
else if(i>0 and s[i]<=p[i] and m[i-1]<=s[i])m+=s[i];
else if(i>0 and p[i]<=s[i] and m[i-1]<=s[i])m+=s[i];
}
if(m.size()!=n)cout<<"No\n";
else
cout<<"Yes\n";
}
int main()
{
int t;
cin >> t;
while (t--)
{
error();
}
}
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:45:58
- Judged At
- 2024-12-07 10:45:58
- Judged By
- Score
- 1
- Total Time
- 18ms
- Peak Memory
- 564.0 KiB