CF812A.Sagheer and Crossroads

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 33 lanes getting into the intersection (one for each direction) and 33 lanes getting out of the intersection, so we have 44 parts in total. Each part has 44 lights, one for each lane getting into the intersection ( ll — left, ss — straight, rr — right) and a light pp 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.

输入格式

The input consists of four lines with each line describing a road part given in a counter-clockwise order.

Each line contains four integers ll , ss , rr , pp — for the left, straight, right and pedestrian lights, respectively. The possible values are 00 for red light and 11 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 11 can hit pedestrians of parts 11 and 44 . Also, cars of parts 22 and 33 can hit pedestrians of part 44 .

In the second example, no car can pass the pedestrian crossing of part 44 which is the only green pedestrian light. So, no accident can occur.

首页