CF225A.Dice Tower
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
A dice is a cube, its faces contain distinct integers from 1 to 6 as black points. The sum of numbers at the opposite dice faces always equals 7. Please note that there are only two dice (these dices are mirror of each other) that satisfy the given constraints (both of them are shown on the picture on the left).

Alice and Bob play dice. Alice has built a tower from n dice. We know that in this tower the adjacent dice contact with faces with distinct numbers. Bob wants to uniquely identify the numbers written on the faces of all dice, from which the tower is built. Unfortunately, Bob is looking at the tower from the face, and so he does not see all the numbers on the faces. Bob sees the number on the top of the tower and the numbers on the two adjacent sides (on the right side of the picture shown what Bob sees).
Help Bob, tell whether it is possible to uniquely identify the numbers on the faces of all the dice in the tower, or not.
骰子是一个立方体,其六个面上分别标有 1 到 6 的互不相同的整数(以黑点表示)。任意一对相对面上的数字之和恒为 7。请注意,仅存在两种满足上述约束条件的骰子(二者互为镜像),它们均显示在左侧图中。

爱丽丝与鲍勃玩骰子游戏。爱丽丝用 $ n $ 个骰子搭成了一座塔。已知在这座塔中,相邻两个骰子接触的面所标的数字互不相同。鲍勃希望唯一确定构成该塔的所有骰子各面上的数字。但不幸的是,鲍勃是从正前方观察这座塔,因此他无法看到所有面上的数字。鲍勃仅能看到塔顶的数字,以及两个相邻侧面的数字(图中右侧展示了鲍勃所见的情形)。
请帮助鲍勃判断:是否能够唯一确定塔中所有骰子各面上的数字?
输入格式
The first line contains a single integer n (1 ≤ n ≤ 100) — the number of dice in the tower.
The second line contains an integer x (1 ≤ x ≤ 6) — the number Bob sees at the top of the tower. Next n lines contain two space-separated integers each: the i-th line contains numbers a__i, b__i (1 ≤ a__i, b__i ≤ 6; a__i ≠ b__i) — the numbers Bob sees on the two sidelong faces of the i-th dice in the tower.
Consider the dice in the tower indexed from top to bottom from 1 to n. That is, the topmost dice has index 1 (the dice whose top face Bob can see). It is guaranteed that it is possible to make a dice tower that will look as described in the input.
第一行包含一个整数 n(1≤n≤100)—— 表示塔中骰子的数量。
第二行包含一个整数 x(1≤x≤6)—— 表示 Bob 在塔顶所看到的数字。接下来的 n 行,每行包含两个用空格分隔的整数:第 i 行包含数字 ai,bi(1≤ai,bi≤6;ai=bi)—— 表示 Bob 在塔中第 i 个骰子的两个侧面上所看到的数字。
将塔中的骰子从上到下依次编号为 1 到 n。即,最顶端的骰子编号为 1(也就是 Bob 能看见其顶面的那个骰子)。题目保证存在一种骰子堆叠方式,使得其外观与输入描述完全一致。
输出格式
Print "YES" (without the quotes), if it is possible to to uniquely identify the numbers on the faces of all the dice in the tower. If it is impossible, print "NO" (without the quotes).
如果可以唯一确定塔中所有骰子各面上的数字,则输出 "YES"(不带引号);否则输出 "NO"(不带引号)。
输入输出样例
输入#1
3 6 3 2 5 4 2 4
输出#1
YES
输入#2
3 3 2 6 4 1 5 3
输出#2
NO
输入解题思路,AI测评打分。不知道怎么写?