Source Code
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define ll long long
#define pb push_back
#define cin(x) for(auto &i:x)cin>>i;
#define copy(x,y) for(int i = 0 ; i < x.size();i++)x[i]=y[i];
using namespace std;
const ll MOD = 1000000007;
const double PI = 3.14159265358979323846;
int find(vector<auto> v,auto target)
{
    for (int i = 0; i < v.size(); i++)
    {
        if(v[i]==target)
            return i;
    }
    return -1;
}
int rfind(vector<auto> v,auto target)
{
   for (int i = v.size()-1; i >= 0; i--)
    {
        if(v[i]==target)
            return i;
    }
    return -1;
}
void solve()
{
   int n;
   cin>>n;
   string s,t;
   cin>>s>>t;
   map<char,int> ms,mt;
   for (int i = 0; i < n; i++)
   {
	  ms[s[i]]++;
   }
   for (int i = 0; i < n; i++)
   {
	  mt[t[i]]++;
   }
   for(auto i : ms)
   {
	  if(i.second != mt[i.first])
      {
		  cout<<"no\n";
		  return ;
	  }
   }
   for (int i = 0; i < n; i++)
   {
	   if(s[i]>='0' and s[i]<='9' and t[i]>='0' and t[i]<='9' and s[i]!=t[i] )
	    {
	     cout<<"no\n";
         return;
	    }
   }
   cout<<"yes\n";
}
int main()
{
   FAST;
   int t=1;	
   cin>>t;
   while(t--)
    solve();
}
Copy
Moving Digits moathhamudah
GNU G++17
4 ms
480 KB
Wrong Answer