Secret Chamber at Mount Rushmore

By now you have probably heard that there is a spectacular stone sculpture featuring four famous U.S. presidents at Mount Rushmore. However, very few people know that this monument contains a secret chamber. This sounds like something out of a plot of a Hollywood movie, but the chamber really exists. It can be found behind the head of Abraham Lincoln and was designed to serve as a Hall of Records to store important historical U.S. documents and artifacts. Historians claim that the construction of the hall was halted in 1939 and the uncompleted chamber was left untouched until the late 1990s, but this is not the whole truth.

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 mm (1m5001≤m≤500) and nn (1n501≤n≤50), where mm is the number of translations of letters and nn is the number of word pairs. Each of the next mm lines contains two distinct space-separated letters aa and bb, indicating that the letter aa can be translated to the letter bb. Each ordered pair of letters (a,b)(a,b) appears at most once. Following this are nn lines, each containing a word pair to check. Translations and words use only lowercase letters ‘a’–‘z’, and each word contains at least 11 and at most 5050 letters.

Output

For each pair of words, display yes if the two words match, and no otherwise.

Sample Input 1Sample Output 1
9 5
c t
i r
k p
o c
r o
t e
t f
u h
w p
we we
can the
work people
it of
out the
yes
no
no
yes
yes

Sample Input 2Sample Output 2
3 3
a c
b a
a b
aaa abc
abc aaa
acm bcm
yes
no
yes

比赛的时候没有看懂题意,题目的意思就是有m组字母,n组词,每组的前一个字母可以推出后一个字母,并且,如果a可以转换为b,b可以转化为c,那么a也可以转换为c。 n组词,如果前者经过转换变为后者输出yes,否则输出no

#include <iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<string.h>
#include<map>
#include<queue>
using namespace std;
int main()
{
    int m,n;
    cin>>m>>n;
    int a[26][26];
    memset(a,0,sizeof(a));
    for(int i=0;i<26;i++)
        a[i][i]=1;//不用转换
    for(int i=0; i<m; i++)
    {
       string s3,s4;
       cin>>s3>>s4;
       a[s3[0]-'a'][s4[0]-'a']=1;
    }
    for(int k=0;k<26;k++)
        for(int i=0;i<26;i++)
        for(int j=0;j<26;j++)//a->b,b->c,a->c;
    {
        if(!a[i][j])
        {
            if(a[i][k]&&a[k][j])
                a[i][j]=1;
        }
    }
    for(int i=0; i<n; i++)
    {
        int flag=0;
        string s1,s2;
        cin>>s1>>s2;
        if(s1.size()!=s2.size())
        {
            printf("no\n");
            continue;
        }
        for(int j=0; j<s1.size(); j++)
        {
            if(!a[s1[j]-'a'][s2[j]-'a'])
            {
               flag=0;
               printf("no\n");
               break;
            }
            flag=1;
        }
        if(flag)
            printf("yes\n");
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ISPE(International Society for Pharmaceutical Engineering)控温室是一种专门用于药物工业的设备,用于控制和维持特定温度条件的封闭环境。它通常用于药品制造、质量控制和研发过程中,以确保药品的稳定性和质量。 ISPE控温室具有以下特点: 1. 温度控制:ISPE控温室具备精确的温度控制功能,可以根据需要设置和维持特定的温度范围。这对于药品质量和稳定性至关重要,因为许多药物的有效性和物化特性会随温度变化而改变。通过控温,药品制造商和研究人员可以在稳定的温度条件下进行研发和生产,以确保药品质量符合预期。 2. 精确度和稳定性:ISPE控温室设计和制造时注重精度和稳定性。它采用高精度的温度控制系统和优质的绝缘材料,以减少温度波动和外界温度对内部环境的影响。这种设计保证了控温室内部能够提供准确、稳定的温度环境,使药品制造过程更加可靠和重复性。 3. 安全性:ISPE控温室还具备重要的安全功能。它配备了安全措施,如过温保护系统和报警装置,以确保在温度异常或意外情况下能及时采取措施避免药品受损或危害人员安全。控温室还可以提供密封的环境,减少外部污染物和湿度对药品质量的影响。 总之,ISPE控温室是一种用于药物工业的设备,旨在提供精确稳定的温度环境,以确保药品的质量和稳定性。通过控温室,药品制造商和研究人员可以在一定温度范围内进行研发、生产和质量控制,满足监管要求并确保药品的安全和有效性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值