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]!='.' and (s[i]-'0')%2==0)
	   {
		   int ind = t.find(s[i]);
		   for (int j = i; j <= ind; j++)
		   {
			   if(t[j]!='.' and (t[j]-'0')&1)
			   {
				   cout<<"no\n";
				   return;
			   }
		   }
		   t[ind]='*';
	   }
   }
   cout<<"yes\n";
}
int main()
{
   FAST;
   int t=1;	
   cin>>t;
   while(t--)
    solve();
}
/*
 * 2..5
 * .52.
 * */
Copy
Moving Digits moathhamudah
GNU G++17
5 ms
608 KB
Wrong Answer