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 & % ...
随机推荐
- EditText取消焦点
EditText取消焦点: 在父容器添加: android:focusable="true" android:focusableInTouchMode="true&quo ...
- C#通过 “枚举数支持在指定类型的集合上进行简单迭代” 的概念获取List的一种方式
using System; using System.Collections.Generic; using System.Linq; namespace myMethod { class Animal ...
- Word Ladder(双向BFS)
2018-10-02 23:46:38 问题描述: 问题求解: 显然是个解空间遍历问题,每次修改其中一位,由于步长是1,所以可以使用BFS进行解空间的遍历.
- gooreplacer 很好用
国内上 StackOverflow, hackernews 之类的站点会慢. 因为页面里有链接指向 google 谷歌, 会被墙. 于是拖累了整个页面的显示. gooreplacer 可以把这些被墙连 ...
- jmap -histo pid 输出的[C [B [I [S 的含义
JMAP 输出 其中: [C is a char[][S is a short[][I is a int[][B is a byte[][[I is a int[][]
- spring boot ----> 和mybatis。。。
环境: centos6.8,jdk1.8.0_172,maven3.5.4,spring boot1.5.15 1.使用maven命令:mvn dependency:tree查看mybatis-spr ...
- mybatis ----> 各种方式使用MBG
1.maven方式使用 配置好.pom文件 ①src/main/resources下创建 generatorConfig.xml,并配置好(自动生成的配置文件骨架) ②src/main/java 下创 ...
- p2725 Stamps
背包. #include <iostream> #include <cstdio> #include <cmath> #include <algorithm& ...
- canvas绘图在手机上边缘粗糙
辛辛苦苦用canvas绘图,做好动画后,想看看效果,结果在手机上一打开,效果是有了,但是边缘特别粗糙,这怎么可以呢,有一种说法是你用canvas绘图时候在手机retain屏幕上,他把一个像素分为两个像 ...
- android--------自定义控件 之 基本实现篇
前面简单的讲述了Android中自定义控件中的几个方法,今天通过代码来实现一个简单的案例 自定义一个扇形图 自定义控件示例: 这里先介绍继承View的方式为例 public class Circula ...