812A.md (2018B)
1 Source: https://codeforces.com/problemset/problem/812/A 2 3 A. Sagheer and Crossroads 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 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. 22 23  24 25 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. 26 27 Now, Sagheer is monitoring the configuration of the traffic lights. Your task is to help him detect whether an accident is possible. 28 29 Input 30 31 The input consists of four lines with each line describing a road part given in a counter-clockwise order. 32 33 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. 34 35 Output 36 37 On a single line, print "YES" if an accident is possible, and "NO" otherwise. 38 39 Examples 40 41 Input 42 43 ``` 44 1 0 0 1 45 0 1 0 0 46 0 0 1 0 47 0 0 0 1 48 ``` 49 50 Output 51 52 ``` 53 YES 54 ``` 55 56 Input 57 58 ``` 59 0 1 1 0 60 1 0 1 0 61 1 1 0 0 62 0 0 0 1 63 ``` 64 65 Output 66 67 ``` 68 NO 69 ``` 70 71 Input 72 73 ``` 74 1 0 0 0 75 0 0 0 1 76 0 0 0 0 77 1 0 1 0 78 ``` 79 80 Output 81 82 ``` 83 NO 84 ``` 85 86 Note 87 88 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. 89 90 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.