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(模拟水体系列)的更多相关文章

  1. UVa 1339 Ancient Cipher --- 水题

    UVa 1339 题目大意:给定两个长度相同且不超过100个字符的字符串,判断能否把其中一个字符串重排后,然后对26个字母一一做一个映射,使得两个字符串相同 解题思路:字母可以重排,那么次序便不重要, ...

  2. uva 1339 Ancient Cipher

    大意:读入两个字符串(都是大写字母),字符串中字母的顺序可以随便排列.现在希望有一种字母到字母的一一映射,从而使得一个字符串可以转换成另一个字符串(字母可以随便排列)有,输出YES:否,输出NO:ex ...

  3. UVa1399.Ancient Cipher

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  4. Poj 2159 / OpenJudge 2159 Ancient Cipher

    1.链接地址: http://poj.org/problem?id=2159 http://bailian.openjudge.cn/practice/2159 2.题目: Ancient Ciphe ...

  5. Ancient Cipher UVa1339

    这题就真的想刘汝佳说的那样,真的需要想象力,一开始还不明白一一映射是什么意思,到底是有顺序的映射?还是没顺序的映射? 答案是没顺序的映射,只要与26个字母一一映射就行 下面给出代码 //Uva1339 ...

  6. poj 2159 D - Ancient Cipher 文件加密

    Ancient Cipher Description Ancient Roman empire had a strong government system with various departme ...

  7. POJ2159 Ancient Cipher

    POJ2159 Ancient Cipher Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 38430   Accepted ...

  8. POJ2159 ancient cipher - 思维题

    2017-08-31 20:11:39 writer:pprp 一开始说好这个是个水题,就按照水题的想法来看,唉~ 最后还是懵逼了,感觉太复杂了,一开始想要排序两串字符,然后移动之类的,但是看了看 好 ...

  9. 2159 -- Ancient Cipher

    Ancient Cipher Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 36074   Accepted: 11765 ...

随机推荐

  1. ios照片获取,拍照功能

    // //  HYBPhotoPickerManager.h //  ehui // //  Created by 黄仪标 on 14/11/26. //  Copyright (c) 2014年 黄 ...

  2. jquery之clone()方法详解

    clone()函数用于克隆当前匹配元素集合的一个副本,并以jQuery对象的形式返回.你也可以简单地理解为:克隆当前jQuery对象. 你还可以指定是否复制这些匹配元素(甚至它们的子元素)的附加数据( ...

  3. [51NOD1090] 3个数和为0(水题,二分)

    题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1090 找到所有数的和,然后再原数组里二分找符合条件的第三个数. ...

  4. JAVA排序--[选择排序]

    package com.array; public class Sort_Select { /** * 项目名称:选择排序 ; * 项目要求:用JAVA对数组进行排序,并运用选择排序算法; * 作者: ...

  5. POJ 3617 Best Cow Line(最佳奶牛队伍)

    POJ 3617 Best Cow Line Time Limit: 1000MS Memory Limit: 65536K [Description] [题目描述] FJ is about to t ...

  6. FLASH CC 2015 CANVAS (四)制作响应式设计(自适应)的项目

    注意 此贴 为个人边“开荒”边写,所以不保证就是最佳做法,也难免有错误(如果发现我会更新文章)! 正式教程会在后续开始更新 相信你在看了(第二节)(第三节)之后已经能够满足绝大多数的互动需求了.那么也 ...

  7. ctDNA 相关网站-liquid-biopsy

    http://www.gene-quantification.de/liquid-biopsy.html Liquid Biopsy -- Definitions Liquid Biopsy -- r ...

  8. BestRW团队项目创意以及NABCD

    一.写在前面 这次的团队项目我们队选到的是自由选题,与其说是选,不如说是分配.毕竟我们组游戏排名倒数第二···其实当我第一次听说我们队排倒数第二的时候我是有点不爽的,毕竟在这后面能够抽到的题目都是剩下 ...

  9. 【51nod】1376 最长递增子序列的数量

    数组A包含N个整数(可能包含相同的值).设S为A的子序列且S中的元素是递增的,则S为A的递增子序列.如果S的长度是所有递增子序列中最长的,则称S为A的最长递增子序列(LIS).A的LIS可能有很多个. ...

  10. hibernate的主键生成策略

    一共是13种,其中包括native native: 对于 oracle 采用 Sequence 方式,对于MySQL 和 SQL Server 采用identity(自增主键生成机制),native就 ...