2017 word finnal i Secret Chamber at Mount Rushmore
来源:互联网 发布:中国电信监控下载软件 编辑:程序博客网 时间:2024/05/21 14:51
In 1982, the famous archaeologist S. Dakota Jones secretly visited the monument and found that the chamber actually was completed, but it was kept confidential. This seemed suspicious and after some poking around, she found a hidden vault and some documents inside. Unfortunately, these documents did not make any sense and were all gibberish. She suspected that they had been written in a code, but she could not decipher them despite all her efforts.
Earlier this week when she was in the area to follow the ACM-ICPC World Finals, Dr. Jones finally discovered the key to deciphering the documents, in Connolly Hall of SDSM&T. She found a document that contains a list of translations of letters. Some letters may have more than one translation, and others may have no translation. By repeatedly applying some of these translations to individual letters in the gibberish documents, she might be able to decipher them to yield historical U.S. documents such as the Declaration of Independence and the Constitution. She needs your help.
You are given the possible translations of letters and a list of pairs of original and deciphered words. Your task is to verify whether the words in each pair match. Two words match if they have the same length and if each letter of the first word can be turned into the corresponding letter of the second word by using the available translations zero or more times.
Input
The first line of input contains two integers
Output
For each pair of words, display yes if the two words match, and no otherwise.
9 5c ti rk po cr ot et fu hw pwe wecan thework peopleit ofout the
yesnonoyesyes
3 3a cb aa baaa abcabc aaaacm bcm
yesnoyes题目很简单,给完对应关系,只要标记好能对应的字符就好了(直接对应或间接对应)
ac代码:
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char a[1000],b[1000];
int data[30][30];
int main()
{
int n,m;
while(cin>>n>>m)
{
char x,y;
memset(data,0,sizeof(data));
for(int i=1; i<=n; i++)
{
getchar();
scanf("%c %c",&x,&y);
data[x-'a'][y-'a']=1;
}
for(int i=0; i<26; i++)
{
for(int j=0; j<26; j++)
{
if(data[i][j]==1)
{
for(int k=0; k<26; k++)
{
if(data[k][i]==1)
data[k][j]=1;
}
}
}
}
for(int p=1; p<=m; p++)
{
scanf("%s %s",a,b);
int lena=strlen(a);
int lenb=strlen(b);
int i=0,j=0,flag=0;
while(i<lena&&j<lenb&&i==j&&flag==0)
{
if(a[i]==b[j]||data[a[i]-'a'][b[j]-'a']==1)
{
i++;
j++;
}
else
flag=1;
}
if(lena==lenb&&flag==0)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
}
return 0;
}
- 2017 word finnal i Secret Chamber at Mount Rushmore
- [bzoj4956]Secret Chamber at Mount Rushmore floyd
- bzoj 4956: Secret Chamber at Mount Rushmore
- 2017 ICPC WF I Secret Chamber at Mount Rushmore【基础/签到】
- 2017 ICPC WF I Secret Chamber at Mount Rushmore(水)
- bzoj 4956: [Wf2017]Secret Chamber at Mount Rushmore(最短路)
- Chemical Secret——2、At home
- 最近做的几条题(4)Secret Word
- JAVA finnal 关键字
- How to let ubuntu mount at startup?
- Secret
- Secret
- Secret
- Java进阶---继承(finnal)
- B. Chamber of Secrets
- Word Ladder I
- Word Ladder I && II
- Word Break I
- 基于Python语言使用RabbitMQ消息队列(四)
- 浏览器兼容性问题汇总及解决方案
- Github全面详解-24为开源项目提交pull request
- hisi gpio_i2c
- IntelliJ IDEA开发Spark、打JAR包
- 2017 word finnal i Secret Chamber at Mount Rushmore
- 核心语法及函数
- 人人学点编程001-简单了解编程语言
- 2017 world final e Need for Speed
- [LeetCode]Reverse Integer
- linux实战应用~redis安装
- Codeforces #206(Div.1) C. Vasya and Beautiful Arrays
- JavaScript常用语法——函数(基础)
- Android 发版的小工具