UVa LA 3213 - Ancient Cipher 水题 难度: 0

时间:2023-03-08 18:21:46

题目

https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1214

题意

问字符串a能否是字符串b经过某种替换+移位密码的密文

思路

明显,计数对的上就行

刘书题目描述不全面

代码

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#define LOCAL_DEBUG
using namespace std;
typedef pair<int, int> MyPair;
int cnta[];
int cntb[]; bool judge(string a, string b) {
memset(cnta, , sizeof cnta);
memset(cntb, , sizeof cntb);
for (int i = ; i < a.size(); i++) {
cnta[a[i]]++;
cntb[b[i]]++;
}
sort(cnta, cnta + );
sort(cntb, cntb + );
for (int i = ; i < ; i++) {
if (cnta[i] != cntb[i])return false;
}
return true;
} int main() {
#ifdef LOCAL_DEBUG
freopen("C:\\Users\\Iris\\source\\repos\\ACM\\ACM\\input.txt", "r", stdin);
//freopen("C:\\Users\\Iris\\source\\repos\\ACM\\ACM\\output.txt", "w", stdout);
#endif // LOCAL_DEBUG
int T;
string a, b;
for (int ti = ;cin>>a>>b; ti++) {
if (judge(a, b))puts("YES");
else puts("NO");
} return ;
}