/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Wrong Answer 3ms 540.0 KiB
#3 Wrong Answer 3ms 540.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios ::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        string s,t;
        cin>>s>>t;
        string s1,t1;
        bool a=true,b=true;
        for(int i=0;i<n-1;i++)
        {
            if(s[i]<=s[i+1])
            {
                s1.push_back(s[i]);
            }
            else
            {
                if(t[i]<s[i+1])
                {
                    s1.push_back(t[i]);
                }
                else
                {
                    a=false;
                    break;
                }
            }
        }
        for(int i=0;i<n-1;i++)
        {
            if(t[i]<=t[i+1])
            {
                t1.push_back(t[i]);
            }
            else
            {
                if(s[i]<t[i+1])
                {
                    t1.push_back(s[i]);
                }
                else
                {
                    b=false;
                    break;
                }
            }
        }

        if(a==false &&  b==false)
        {
            cout<<"No\n";
        }
        else if(a==true || b==true)
        {
            cout<<"Yes\n";
        }
    }
    return 0;
}

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:27:33
Judged At
2024-12-07 10:27:33
Judged By
Score
1
Total Time
3ms
Peak Memory
540.0 KiB