Codeforces 812A-Sagheer and Crossroads
来源:互联网 发布:淘宝新手开店 编辑:程序博客网 时间:2024/05/28 15:58
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.
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.
On a single line, print "YES" if an accident is possible, and "NO" otherwise.
1 0 0 10 1 0 00 0 1 00 0 0 1
YES
0 1 1 01 0 1 01 1 0 00 0 0 1
NO
1 0 0 00 0 0 10 0 0 01 0 1 0
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 3can 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.
题意:一个红绿灯 按逆时针方向一次给出各个路口的左转,直行,右转,以及行人车道,判断汽车是否有可能撞到行人
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <queue>#include <stack>#include <cmath>#include <map>#include <bitset>#include <set>#include <vector>#include <functional>using namespace std;#define LL long longconst int INF = 0x3f3f3f3f;int a[4][4];int main(){while (~scanf("%d%d%d%d", &a[0][0], &a[0][1], &a[0][2], &a[0][3])){for (int i = 1; i < 4; i++) scanf("%d%d%d%d", &a[i][0], &a[i][1], &a[i][2], &a[i][3]);int flag = 0;for (int i = 0; i < 4; i++){if (!a[i][3]) continue;if (a[i][1] ||a[i][0]||a[i][2]|| a[(i + 2) % 4][1] || a[(i + 1) % 4][0] || a[(i - 1 + 4) % 4][2]) flag = 1;}if (flag) printf("YES\n");else printf("NO\n");}return 0;}
- Codeforces 812A-Sagheer and Crossroads
- Codeforces 812A Sagheer and Crossroads[模拟]
- Codeforces 812 A Sagheer and Crossroads
- CodeForces 812A Sagheer and Crossroads
- codeforces 812A Sagheer and Crossroads
- CodeFroces 812A Sagheer and Crossroads
- Codeforces Round #417 (Div. 2) A. Sagheer and Crossroads
- Codeforces Round #417 (Div. 2) A. Sagheer and Crossroads
- Codeforces Round #417 (Div. 2) A. Sagheer and Crossroads
- Codeforces Round #417 (Div. 2)-A. Sagheer and Crossroads-模拟
- Sagheer and Crossroads
- Codeforces812A Sagheer and Crossroads
- Codeforces812A Sagheer and Crossroads
- Codeforces Round #417 (Div. 2) A. Sagheer and Crossroads(模拟)
- Codeforces 812C-Sagheer and Nubian Market
- Codeforces 812 C Sagheer and Nubian Market
- Codeforces 812C Sagheer and Nubian Market
- codeforces 812C Sagheer and Nubian Market
- TI单节电量计基本介绍及常见问题解答
- java中enum的基本特性
- Device Tree(一):背景介绍
- notify()和notifyAll()区别
- rabbit mq配置文件
- Codeforces 812A-Sagheer and Crossroads
- 数字电子技术复习(六)——存储器与可编程逻辑器件
- tar 分包压缩与合并
- 电脑不能开机怎么重装系统?
- 数据库笔试面试22——CREATE、DROP、ALTER语句
- 序列+创建序列
- Android开发之查看SHA1信息
- No source template was found from input data:<{:guid=> [clone vm via /api/provision_requests]
- html5 中的 wbe storage