A8740 | Dice Tower
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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.
输入格式
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.
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.
输出格式
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).
输入输出样例
输入 #1
3 6 3 2 5 4 2 4
输出 #1
YES
输入 #2
3 3 2 6 4 1 5 3
输出 #2
NO
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted