任意划分并重排后可以得到 ,等价于 中出现的字符在 中出现的次数相同。
因此,将 按字典序排序后的结果与 按字典序排序后的结果相同。比较两个字符串按字典序排序后的结果是否相同即可。
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;string s,t;
cin>>n>>s>>t;
sort(s.begin(),s.end());
sort(t.begin(),t.end());
cout<<(s==t?"Yes":"No");
return 0;
}