跳到正文

题解

题解:P13491 【MX-X14-T1】拼凑基因

Hughpig约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年7月26日
收录
2025年12月12日
更新
2026年10月28日
篇幅
约 1 分钟
获赞
3
题目
P13491

版本

  1. v1当前

SS 任意划分并重排后可以得到 TT,等价于 SS 中出现的字符在 TT 中出现的次数相同。

因此,将 SS 按字典序排序后的结果与 TT 按字典序排序后的结果相同。比较两个字符串按字典序排序后的结果是否相同即可。

C++
#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;
}
原文