uva--1339 - Ancient Cipher(模拟水体系列)
1339 - Ancient Cipher
Ancient Roman empire had a strong government system with various departments, including a secret service department. Important documents were sent between provinces and the capital in encrypted form to prevent eavesdropping. The most popular ciphers in those times were so called substitution cipher and permutation cipher. Substitution cipher changes all occurrences of each letter to some other letter. Substitutes for all letters must be different. For some letters substitute letter may coincide with the original letter. For example, applying substitution cipher that changes all letters from `A' to `Y' to the next ones in the alphabet, and changes `Z' to `A', to the message ``VICTORIOUS'' one gets the message ``WJDUPSJPVT''. Permutation cipher applies some permutation to the letters of the message. For example, applying the permutation 2, 1, 5, 4, 3, 7, 6, 10, 9, 8 to the message ``VICTORIOUS'' one gets the message ``IVOTCIRSUO''. It was quickly noticed that being applied separately, both substitution cipher and permutation cipher were rather weak. But when being combined, they were strong enough for those times. Thus, the most important messages were first encrypted using substitution cipher, and then the result was encrypted using permutation cipher. Encrypting the message ``VICTORIOUS'' with the combination of the ciphers described above one gets the message ``JWPUDJSTVP''. Archeologists have recently found the message engraved on a stone plate. At the first glance it seemed completely meaningless, so it was suggested that the message was encrypted with some substitution and permutation ciphers. They have conjectured the possible text of the original message that was encrypted, and now they want to check their conjecture. They need a computer program to do it, so you have to write one.
Input
Input file contains several test cases. Each of them consists of two lines. The first line contains the message engraved on the plate. Before encrypting, all spaces and punctuation marks were removed, so the encrypted message contains only capital letters of the English alphabet. The second line contains the original message that is conjectured to be encrypted in the message on the first line. It also contains only capital letters of the English alphabet. The lengths of both lines of the input file are equal and do not exceed 100.
Output
For each test case, print one output line. Output `YES' if the message on the first line of the input file could be the result of encrypting the message on the second line, or `NO' in the other case.
Sample Input
JWPUDJSTVP
VICTORIOUS
MAMA
ROME
HAHA
HEHE
AAA
AAA
NEERCISTHEBEST
SECRETMESSAGES
Sample Output
YES
NO
YES
YES
NO
题意: 给你两个串a,b 需要你将a的每一类字母进行变换问能否得到b串
很简单的一个题目:
HAHA
HEHE 以这个为列子; 两种类型的字母,只需要比较a,b将所有类型的字母所形成的的数据一样,即他们能够有一样的个数需要一样,但是字母不需要相同 代码:
//#define LOCAL
#include<cstdio>
#include<cmath>
#include<cstring>
char a[],b[];
int c[],d[],e[]; int main()
{
int i;
#ifdef LOCAL
freopen("test.in","r",stdin);
#endif
while(scanf("%s%s",a,b)!=EOF){
memset(c,,sizeof(c));
memset(d,,sizeof(d));
memset(e,,sizeof(e));
for(i=;a[i]!='\0';i++){
c[a[i]-'A']++;
d[b[i]-'A']++;
}
for(i=;i<;i++)
{
e[c[i]]++;
e[d[i]]--;
}
for(i=;i<=;i++)
if(e[i])break;
puts(i>?"YES":"NO");
}
return ;
}
uva--1339 - Ancient Cipher(模拟水体系列)的更多相关文章
- UVa 1339 Ancient Cipher --- 水题
UVa 1339 题目大意:给定两个长度相同且不超过100个字符的字符串,判断能否把其中一个字符串重排后,然后对26个字母一一做一个映射,使得两个字符串相同 解题思路:字母可以重排,那么次序便不重要, ...
- uva 1339 Ancient Cipher
大意:读入两个字符串(都是大写字母),字符串中字母的顺序可以随便排列.现在希望有一种字母到字母的一一映射,从而使得一个字符串可以转换成另一个字符串(字母可以随便排列)有,输出YES:否,输出NO:ex ...
- UVa1399.Ancient Cipher
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- Poj 2159 / OpenJudge 2159 Ancient Cipher
1.链接地址: http://poj.org/problem?id=2159 http://bailian.openjudge.cn/practice/2159 2.题目: Ancient Ciphe ...
- Ancient Cipher UVa1339
这题就真的想刘汝佳说的那样,真的需要想象力,一开始还不明白一一映射是什么意思,到底是有顺序的映射?还是没顺序的映射? 答案是没顺序的映射,只要与26个字母一一映射就行 下面给出代码 //Uva1339 ...
- poj 2159 D - Ancient Cipher 文件加密
Ancient Cipher Description Ancient Roman empire had a strong government system with various departme ...
- POJ2159 Ancient Cipher
POJ2159 Ancient Cipher Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 38430 Accepted ...
- POJ2159 ancient cipher - 思维题
2017-08-31 20:11:39 writer:pprp 一开始说好这个是个水题,就按照水题的想法来看,唉~ 最后还是懵逼了,感觉太复杂了,一开始想要排序两串字符,然后移动之类的,但是看了看 好 ...
- 2159 -- Ancient Cipher
Ancient Cipher Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 36074 Accepted: 11765 ...
随机推荐
- sql语句中的注释符号
sql语句中的注释符号 mysql # 到该行结束.-- 到该行结束 以及 的注释方格:mysql> SELECT 1+1; # 这个注释直到该行结束mysql> SELE ...
- CALayer总结(一)
1.geometryFlipped 设置为yes,则子图层或者子视图本来相对于左上角放置 改为 相对于左下角放置: 2.contents 3.contentGravity: kCAGravityC ...
- HNOI2006-鬼谷子的钱袋
鬼谷子的钱袋 鬼谷子非常聪明,正因为这样,他非常繁忙,经常有各诸侯车的特派员前来向他咨询时政.有一天,他在咸阳游历的时候,朋友告诉他在咸阳最大的拍卖行(聚宝商行)将要举行一场拍卖会,其中有一件宝物引起 ...
- STORM_0003_linux_zookeeper_storm_遇到的几个问题
1. 首先是花费时间在windows的eclipse下面安装fatjar因为是新版的缘故,装了很久才装上. 后来发现其实mvn可以打包出没有依赖的jar包 2. 然后是按照在ubuntu环境中的mvn ...
- JSP学习——原理
JSP全称是Java Server Pages,它和servle技术一样,都是SUN公司定义的一种用于开发动态web资源的技术. JSP这门技术的最大的特点在于,写jsp就像在写html,但它相比 ...
- iOS - Swift NSData 数据
前言 public class NSData : NSObject, NSCopying, NSMutableCopying, NSSecureCoding public class NSMutabl ...
- [转载] Google大数据引擎Dremel剖析(1)
原文: https://mp.weixin.qq.com/s?__biz=MjM5NzAyNTE0Ng==&mid=207895956&idx=1&sn=58e8af26fd3 ...
- HDU4801·二阶魔方
题意:给定二阶魔方初始状态,问N(1 <= N <= 7)步旋转操作以内最多能使几个面相同. dfs搜索+剪枝. 魔方的每个旋转操作即对应于一个置换操作.又因为相对运动,上层左旋一次和下层 ...
- 2014 Multi-University Training Contest 1
A hdu4861 打表找规律 #include <iostream> #include<cstdio> #include<cstring> #include< ...
- [转]Java代码(性能)优化总结
前言 代码优化,一个很重要的课题.可能有些人觉得没用,一些细小的地方有什么好修改的,改与不改对于代码的运行效率有什么影响呢?这个问题我是这么考虑的,就像大海里面的鲸鱼一样,它吃一条小虾米有用吗?没用, ...