CF689A.Mike and Cellphone
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way:

Together with his old phone, he lost all his contacts and now he can only remember the way his fingers moved when he put some number in. One can formally consider finger movements as a sequence of vectors connecting centers of keys pressed consecutively to put in a number. For example, the finger movements for number "586" are the same as finger movements for number "253":


Mike has already put in a number by his "finger memory" and started calling it, so he is now worrying, can he be sure that he is calling the correct number? In other words, is there any other number, that has the same finger movements?
迈克在海滩游泳时,不小心把手机掉进了水里。他并不担心,因为他买了一部便宜的备用手机,配备了一个老式的键盘。该键盘仅有十个大小相等的数字键,排列方式如下:

与此同时,他丢失了旧手机中所有的联系人;如今,他只能凭记忆回想起输入某个号码时手指的移动轨迹。我们可以将手指移动形式化地定义为:一系列向量,每个向量连接连续按下的两个键的中心点,从而构成输入一个数字时的完整运动序列。例如,输入数字“586”时的手指移动轨迹,与输入数字“253”时完全相同:


迈克已凭“手指记忆”输入了一个号码并开始拨号,因此他现在十分担忧:自己能否确定正在拨打的是正确的号码?换言之,是否存在另一个不同的数字,其对应的手指移动轨迹完全相同?
输入格式
The first line of the input contains the only integer n (1 ≤ n ≤ 9) — the number of digits in the phone number that Mike put in.
The second line contains the string consisting of n digits (characters from '0' to '9') representing the number that Mike put in.
输入的第一行包含唯一一个整数 n(1≤n≤9)——表示 Mike 输入的电话号码的位数。
第二行包含一个由 n 个数字(字符 '0' 到 '9')组成的字符串,表示 Mike 输入的号码。
输出格式
If there is no other phone number with the same finger movements and Mike can be sure he is calling the correct number, print "YES" (without quotes) in the only line.
Otherwise print "NO" (without quotes) in the first line.
如果不存在其他具有相同手指移动轨迹的电话号码,且 Mike 可以确定自己拨打的是正确的号码,则在唯一一行中输出 "YES"(不带引号)。
否则,在第一行中输出 "NO"(不带引号)。
输入输出样例
输入#1
3 586
输出#1
NO
输入#2
2 09
输出#2
NO
输入#3
9 123456789
输出#3
YES
输入#4
3 911
输出#4
YES
说明/提示
You can find the picture clarifying the first sample case in the statement above.
您可以在上述题面中找到用于说明第一个样例的图片。
输入解题思路,AI测评打分。不知道怎么写?