跳到正文

题解

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

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

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟
题目
P13491

版本

  1. v1当前

这题太水了吧,把我在场上卡了四下

我们找俩数组,分别存储两个字符串每个字母的频数即可。

然后这题就秒掉了

C++
#include<bits/stdc++.h>
using namespace std;
int n;
string s, t;
int a[26], b[26];
bool f() {
    for (char c : s) a[c - 'a']++;
    for (char c : t) b[c - 'a']++;
    for (int i = 0; i < 26; i++)
        if (a[i] != b[i]) return false;
    return true;
}
int main() {
    cin >> n >> s >> t;
    cout << (f() ? "Yes" : "No") << endl;
    return 0;
}
原文