General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
160812483 Practice:
_Alamin_Bhuiyan_
1697C - 16 C++17 (GCC 7-32) Time limit exceeded on test 10 2000 ms 508 KB 2022-06-16 15:12:57 2022-06-16 15:12:57
→ Source
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using    namespace __gnu_pbds;

using    namespace std;

typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


#define FAST        ios_base::sync_with_stdio(false);
#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>

#define mod         1000000007

void expt(ll cs)
{
    ll n,i,j,m,k=0,cnt=0,ans=0,res=0,sum=0;
    cin >> n;
    string s,t;
    cin >> s >> t;
    for(i = 0; i < n; i++)
    {
        if(s[i] == t[i])continue;
        if(s[i] == 'a' && t[i] == 'b')
        {
            j = i+1;
            while(j<n && s[j] == 'a')
                j++;
            if(j<n && s[j] == 'b')
            {
                s[j] = 'a';
                s[i] = 'b';
            }
            else
                break;
        }
        else if(s[i] == 'b' && t[i] == 'c')
        {
            j = i+1;
            while(j<n && s[j] == 'b')
                j++;
            if(j<n && s[j] == 'c')
            {
                s[j] = 'b';
                s[i] = 'c';
            }
            else
                break;
        }
        else
            break;
    }
    if(s==t)
    cout << "YES" <<endl;
    else
    cout << "NO" <<endl;

}


int main()
{
    FAST
    ll t,cs=0;

    cin>>t;while(t--)
    {
        cs++;
        expt(cs);
    }
    return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details