A11044 | Sagheer and Crossroads
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Sagheer is walking in the street when he comes to an intersection of two roads. Each road can be represented as two parts where each part has $3$ lanes getting into the intersection (one for each direction) and $3$ lanes getting out of the intersection, so we have $4$ parts in total. Each part has $4$ lights, one for each lane getting into the intersection ( $l$ — left, $s$ — straight, $r$ — right) and a light $p$ for a pedestrian crossing.
An accident is possible if a car can hit a pedestrian. This can happen if the light of a pedestrian crossing of some part and the light of a lane that can get to or from that same part are green at the same time.
Now, Sagheer is monitoring the configuration of the traffic lights. Your task is to help him detect whether an accident is possible.
An accident is possible if a car can hit a pedestrian. This can happen if the light of a pedestrian crossing of some part and the light of a lane that can get to or from that same part are green at the same time.
Now, Sagheer is monitoring the configuration of the traffic lights. Your task is to help him detect whether an accident is possible.
输入格式
The input consists of four lines with each line describing a road part given in a counter-clockwise order.
Each line contains four integers $l$ , $s$ , $r$ , $p$ — for the left, straight, right and pedestrian lights, respectively. The possible values are $0$ for red light and $1$ for green light.
Each line contains four integers $l$ , $s$ , $r$ , $p$ — for the left, straight, right and pedestrian lights, respectively. The possible values are $0$ for red light and $1$ for green light.
输出格式
On a single line, print "YES" if an accident is possible, and "NO" otherwise.
输入输出样例
输入 #1
1 0 0 1 0 1 0 0 0 0 1 0 0 0 0 1
输出 #1
YES
输入 #2
0 1 1 0 1 0 1 0 1 1 0 0 0 0 0 1
输出 #2
NO
输入 #3
1 0 0 0 0 0 0 1 0 0 0 0 1 0 1 0
输出 #3
NO
In the first example, some accidents are possible because cars of part $1$ can hit pedestrians of parts $1$ and $4$ . Also, cars of parts $2$ and $3$ can hit pedestrians of part $4$ .
In the second example, no car can pass the pedestrian crossing of part $4$ which is the only green pedestrian light. So, no accident can occur.
In the second example, no car can pass the pedestrian crossing of part $4$ which is the only green pedestrian light. So, no accident can occur.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted