WTMGB

题目链接

题目描述

YellowStar is very happy that the FZU Code Carnival is about to begin except that he has to prepare problems for it. Because the statement of each problem is written in English!

YellowStar types the statements slowly witb high error rate. You must notice that the previous word ’witb’ is wrong(the correct word is ’with’). But YellowStar feels too tired, so he thinks a word is the same as another word if the character at each position of the word is adjacent to the corresponding character of the other word on the keyboard. The keyboard is shown in the figure below:

When two characters on ther keyboard have intersections, they are considered to be adjacent. For example,’S’ is adjacent to ’W’,’E’,’A’,’D’,’Z’ and ’X’.

Now YellowStar asks you to write a program to check whether two strings are the same. Print ’Yes’ if they are the same, and ’No’ otherwise(without the quotes).

输入

Input is given from Standard Input in the following format:

S1

S2

Constraints

1 ≤ | S1 | = | S2 | ≤ 103

S1 and S2 consist only of upper-case English letters.

输出

Print one line denotes the answer.

样例输入

S
U

样例输出

No

题解

简单模拟 但我写的太长太慢了

代码

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define scac(x) scanf("%c",&x)
#define sca(x) scanf("%d",&x)
#define sca2(x,y) scanf("%d%d",&x,&y)
#define sca3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scl(x) scanf("%lld",&x)
#define scl2(x,y) scanf("%lld%lld",&x,&y)
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pri(x) printf("%d\n",x)
#define pri2(x,y) printf("%d %d\n",x,y)
#define pri3(x,y,z) printf("%d %d %d\n",x,y,z)
#define prl(x) printf("%lld\n",x)
#define prl2(x,y) printf("%lld %lld\n",x,y)
#define prl3(x,y,z) printf("%lld %lld %lld\n",x,y,z)
#define ll long long
#define LL long long
inline ll read(){ll x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;}
#define read read()
#define pb push_back
#define mp make_pair
#define P pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(1.0)
#define eps 1e-6
#define inf 1e17
#define INF 0x3f3f3f3f
#define MOD 998244353
#define mod 1e9+7
#define N 1000005
const int maxn=2000005;
string s1,s2;
int e[28][28];
void add(int a,int b)
{
e[a][b] = 1;
e[b][a] = 1;
}
void Init()
{
add('Q' - 'A','W' - 'A');
add('Q' - 'A','A' - 'A');
add('W' - 'A','E' - 'A');
add('W' - 'A','S' - 'A');
add('W' - 'A','A' - 'A');
add('E' - 'A','S' - 'A');
add('E' - 'A','R' - 'A');
add('E' - 'A','D' - 'A');
add('R' - 'A','T' - 'A');
add('R' - 'A','F' - 'A');
add('R' - 'A','D' - 'A');
add('T' - 'A','Y' - 'A');
add('T' - 'A','G' - 'A');
add('T' - 'A','F' - 'A');
add('Y' - 'A','U' - 'A');
add('Y' - 'A','H' - 'A');
add('Y' - 'A','G' - 'A');
add('U' - 'A','J' - 'A');
add('U' - 'A','I' - 'A');
add('U' - 'A','H' - 'A');
add('I' - 'A','O' - 'A');
add('I' - 'A','K' - 'A');
add('I' - 'A','J' - 'A');
add('O' - 'A','K' - 'A');
add('O' - 'A','L' - 'A');
add('O' - 'A','P' - 'A');
add('P' - 'A','L' - 'A');
add('A' - 'A','S' - 'A');
add('A' - 'A','Z' - 'A');
add('S' - 'A','D' - 'A');
add('S' - 'A','X' - 'A');
add('S' - 'A','Z' - 'A');
add('D' - 'A','F' - 'A');
add('D' - 'A','C' - 'A');
add('D' - 'A','X' - 'A');
add('F' - 'A','G' - 'A');
add('F' - 'A','V' - 'A');
add('F' - 'A','C' - 'A');
add('G' - 'A','H' - 'A');
add('G' - 'A','B' - 'A');
add('G' - 'A','V' - 'A');
add('H' - 'A','J' - 'A');
add('H' - 'A','N' - 'A');
add('H' - 'A','B' - 'A');
add('J' - 'A','K' - 'A');
add('J' - 'A','M' - 'A');
add('J' - 'A','N' - 'A');
add('K' - 'A','L' - 'A');
add('K' - 'A','M' - 'A');
add('Z' - 'A','X' - 'A');
add('X' - 'A','C' - 'A');
add('C' - 'A','V' - 'A');
add('V' - 'A','B' - 'A');
add('B' - 'A','N' - 'A');
add('N' - 'A','M' - 'A');
}
int main()
{
string s1,s2;
for(int i = 0; i<26;i++)
{
e[i][i] = 1;
}
Init();
cin >>s1 >> s2;
int flag =1 ;
for(int i = 0;i <s1.length();i++)
{
if(e[s1[i] - 'A'][s2[i] - 'A']) continue;
else{
flag = 0;
break;
}
}
if(flag ) cout << "Yes" <<endl;
else cout <<"No" <<endl;
return 0;
}
/*
5
1 6 9 8 3
2 5 6 7 9
*/

upc组队赛16 WTMGB【模拟】的更多相关文章

  1. upc组队赛16 Winner Winner【位运算】

    Winner Winner 题目链接 题目描述 The FZU Code Carnival is a programming competetion hosted by the ACM-ICPC Tr ...

  2. upc组队赛16 GCDLCM 【Pollard_Rho大数质因数分解】

    GCDLCM 题目链接 题目描述 In FZU ACM team, BroterJ and Silchen are good friends, and they often play some int ...

  3. upc组队赛16 Melody【签到水】

    Melody 题目描述 YellowStar is versatile. One day he writes a melody A = [A1, ..., AN ], and he has a sta ...

  4. 10.16 NOIP模拟赛

    目录 2018.10.16 NOIP模拟赛 A 购物shop B 期望exp(DP 期望 按位计算) C 魔法迷宫maze(状压 暴力) 考试代码 C 2018.10.16 NOIP模拟赛 时间:2h ...

  5. upc组队赛6 Progressive Scramble【模拟】

    Progressive Scramble 题目描述 You are a member of a naive spy agency. For secure communication,members o ...

  6. upc组队赛3 Congestion Charging Zon【模拟】

    Congestion Charging Zon 题目描述 Tehran municipality has set up a new charging method for the Congestion ...

  7. upc组队赛15 Lattice's basics in digital electronics【模拟】

    Lattice's basics in digital electronics 题目链接 题目描述 LATTICE is learning Digital Electronic Technology. ...

  8. upc组队赛18 THE WORLD【时间模拟】

    THE WORLD 题目链接 题目描述 The World can indicate world travel, particularly on a large scale. You mau be l ...

  9. upc 组队赛18 STRENGTH【贪心模拟】

    STRENGTH 题目链接 题目描述 Strength gives you the confidence within yourself to overcome any fears, challeng ...

随机推荐

  1. C. Trailing Loves (or L'oeufs?) (质因数分解)

    C. Trailing Loves (or L'oeufs?) 题目传送门 题意: 求n!在b进制下末尾有多少个0? 思路: 类比与5!在10进制下末尾0的个数是看2和5的个数,那么 原题就是看b进行 ...

  2. python学习第二十五天函数位置参数和关键词参数

    函数位置参数顾名思义就是按位置排序,按位置对应参数,位置一一对应,函数的关键词参数是不按照顺序来的,可以指定的参数传值.但是注意的是,位置参数必须在关键词参数之前. 1,函数位置参数 def good ...

  3. SQL server 聚集索引与主键的区别

    主键是一个约束(constraint),他依附在一个索引上,这个索引可以是聚集索引,也可以是非聚集索引. 所以在一个(或一组)字段上有主键,只能说明他上面有个索引,但不一定就是聚集索引. 例如下面: ...

  4. 实现combobox模糊查询的时候报错 InvalidArgument=“0”的值对于“index”无效

    因为要对combobox实现模糊查询,因为系统实现的匹配只能从左到右进行匹配,所以利用两个list来进行模糊匹配,主要代码如下: List<string> listOnit = new L ...

  5. JWT 实现基于API的用户认证

    基于 JWT-Auth 实现 API 验证 如果想要了解其生成Token的算法原理,请自行查阅相关资料 需要提及的几点: 使用session存在的问题: session和cookie是为了解决http ...

  6. GeneXus笔记本—常用函数(上)

    国庆放假没事怎么办?写点笔记充会儿电! ≖‿≖✧   哈哈哈 !!最近在参与公司的其中一个项目中,发现了一些函数自己没见过 也没使用过,但是这些函数都是GeneXus中自带的一些 这此记录的目的就是为 ...

  7. linux改变内核参数

  8. 如何为nginx配置https(免费证书)

    前言: 给http协议申请ssl免费证书,还是比较主流的一种方式,但是逐渐得一些浏览器不支持自签名的证书了.毕竟这是为了使用者及平台都变得安全的方式,所以无可厚非的,而且也有很多网站即使不使用商业付费 ...

  9. Java疯狂讲义笔记——Lambda表达式

    Java8新增的Lambda表达式 [特性]支持将代码块作为方法参数,Lambda表达式允许使用更简洁的代码来创建只有一个抽象方法的接口(这种接口被称为函数式接口)的实例. [组成部分]1,形参列表 ...

  10. 四、Angular新建组件和使用

    1.新建组件命令 ng component 组件路径 如果报错换成 ng generate component 组件路径 2.组件 ts 文件详解 3.组件会自动引入到app.mudule.ts里面 ...