Codeforces Round 417 (Div. 2)
A
Sagheer and Crossroads
Codeforces
1200
原题
←B →
翻译中…

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.

翻译中…

image

翻译中…

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.

翻译中…

Input

翻译中…

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.

翻译中…

Output

翻译中…

On a single line, print "YES" if an accident is possible, and "NO" otherwise.

翻译中…

Note

翻译中…

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.

翻译中…

样例

Input #1
1 0 0 1
0 1 0 0
0 0 1 0
0 0 0 1
Output #1
YES
InputCopy OutputCopy
Input #2
0 1 1 0
1 0 1 0
1 1 0 0
0 0 0 1
Output #2
NO
InputCopy OutputCopy
Input #3
1 0 0 0
0 0 0 1
0 0 0 0
1 0 1 0
Output #3
NO
InputCopy OutputCopy
题目信息
题号
812A
时间限制
1 s
内存限制
256 MB
标签
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。