UVa LA 3213 - Ancient Cipher 水题 难度: 0
题目
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 ;
}
UVa LA 3213 - Ancient Cipher 水题 难度: 0的更多相关文章
- UVa 10340 - All in All 水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVa 3602 - DNA Consensus String 水题 难度: 0
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- UVa 1339 Ancient Cipher --- 水题
UVa 1339 题目大意:给定两个长度相同且不超过100个字符的字符串,判断能否把其中一个字符串重排后,然后对26个字母一一做一个映射,使得两个字符串相同 解题思路:字母可以重排,那么次序便不重要, ...
- LA 3213 Ancient Cipher (水题,转化)
题意:给定两个长度相同的字符串,判断它们之间是否存在一一对应关系,顺序不定. 析:刚开始没看到顺序不定,然后写完没胡把样例看完就交了,结果WA了一次...其实这是一个水题,既然顺序不定,那么更简单,我 ...
- UVa 10970 - Big Chocolate 水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVa 11039 - Building designing 贪心,水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVa 11636 - Hello World! 二分,水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- LA 3213 Ancient Cipher
开始我理解错题意了,应该是这样理解的: 字符串1进行映射后可以做一个置换,若置换后与字符串2相同,也是输出YES的 比如ABCA 和 DDEF 因此我们需要做的就是统计有多少类字母,每一类有多少个,如 ...
- hdu 3687 10 杭州 现场 H - National Day Parade 水题 难度:0
H - National Day Parade Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & % ...
随机推荐
- 学习笔记41—ttest误区
1.grapPad软件里面双T结果和matlab,EXCEl里面双T结果一致时,设置如下:
- CC2 条理分明-----AACTP教你谈恋爱
AACTP是一个神奇的地方,这里可以培养你的自信,培养你的沟通表达能力,培养你的领导管理能力:但是你不知道的是AACTP还可以培养你恋爱的本领.想知道是怎么回事吗?听我给你慢慢说来.我把恋爱分为三 ...
- WebStorm Error : program path not specified
1.出现这个错误是由于没有设置Node.js路径引起的. 2.下载安装Node.js. 3.设置对应的路径,设置后点一下Enable按钮即可. 以上,完.
- Error updating database:线程异常
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".SLF4J: See http://www.slf4 ...
- ionic service
当你初试 Angular 时,很自然地就会往 controller 和 scope 里堆满不必要的逻辑.一定要早点意识到,controller 这一层应该很薄:也就是说,应用里大部分的业务逻辑和持久化 ...
- centos php5.4 升级 php7
接上篇,edusoho需要php5.5以上版本,于是需要升级本地php php是通过yum默认安装的.以下安装参考 link https://blog.csdn.net/u012569217/arti ...
- Practical Vim 第一章 & 第二章
第一章:Vim 解决问题的方式 前言 本质上讲,我们的工作是重复性的.凡是可以简化重复性操作的方式,都会成倍地节省我们的时间. Vim 对重复性操作进行了优化.它之所以能高效地重复,是因为它会记录我们 ...
- learn python the hard way 习题6~10总结
习题6总结 定义字符串: 名字 = 值 其他 你也可以用 {types_of_people}的方式把它放在任何字符串中. 也就是说你可以在其他字符串中添加{},然后前面加一个 f,可用print()进 ...
- 大数据量 与 UI交互时的处理 总结与心得
[以下均在主线程中操作时]1.UI直接操作,数据量较大时,直接使用UI会非常慢2.数据驱动操作,数据量较大时,数据与UI的交互效率相比“1”提升明显 总结:但以上这两种操作 都会“较长时间”占用主线 ...
- VS Code行内样式提示插件
打开vscode,在软件界面左下角找到“齿轮”标志并点击,在弹出的菜单中选择“设置”,把下面的代码添加到设置里. { "workbench.colorTheme": "C ...