A. Sagheer and Crossroads
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

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 lsrp —
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.

Examples
input
  1. 1 0 0 1
  2. 0 1 0 0
  3. 0 0 1 0
  4. 0 0 0 1
output
  1. YES
input
  1. 0 1 1 0
  2. 1 0 1 0
  3. 1 1 0 0
  4. 0 0 0 1
output
  1. NO
input
  1. 1 0 0 0
  2. 0 0 0 1
  3. 0 0 0 0
  4. 1 0 1 0
output
  1. NO
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 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.

————————————————————————————————————
题目的意思是给出4个路口的车辆和人的红路灯状态,判断是否可能车撞人

  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cstring>
  4. #include <string>
  5. #include <algorithm>
  6. #include <vector>
  7. #include <queue>
  8. #include <stack>
  9. #include <map>
  10. #include <set>
  11. #include <cmath>
  12.  
  13. using namespace std;
  14.  
  15. #define LL long long
  16. const int inf=0x7fffffff;
  17.  
  18. int main()
  19. {
  20. int a[10][10];
  21. for(int i=1; i<=4; i++)
  22. for(int j=1; j<=4; j++)
  23. scanf("%d",&a[i][j]);
  24. int flag=0;
  25. if(a[1][4]==1&&(a[1][1]==1||a[1][2]==1||a[1][3]==1||a[2][1]==1||a[3][2]==1||a[4][3]==1))
  26. printf("YES\n"),flag=1;
  27. else if(a[2][4]==1&&(a[2][1]==1||a[2][2]==1||a[2][3]==1||a[3][1]==1||a[4][2]==1||a[1][3]==1))
  28. printf("YES\n"),flag=1;
  29. else if(a[3][4]==1&&(a[3][1]==1||a[3][2]==1||a[3][3]==1||a[4][1]==1||a[1][2]==1||a[2][3]==1))
  30. printf("YES\n"),flag=1;
  31. else if(a[4][4]==1&&(a[4][1]==1||a[4][2]==1||a[4][3]==1||a[1][1]==1||a[2][2]==1||a[3][3]==1))
  32. printf("YES\n"),flag=1;
  33. if(flag==0)
  34. printf("NO\n");
  35.  
  36. return 0;
  37. }

Codeforces812A Sagheer and Crossroads 2017-06-02 20:41 139人阅读 评论(0) 收藏的更多相关文章

  1. python如何使用 os.path.exists()--Learning from stackoverflow 分类: python 2015-04-23 20:48 139人阅读 评论(0) 收藏

    Q&A参考连接 Problem:IOError: [Errno 2] No such file or directory. os.path.exists() 如果目录不存在,会返回一个0值. ...

  2. Codeforces812B Sagheer, the Hausmeister 2017-06-02 20:47 85人阅读 评论(0) 收藏

    B. Sagheer, the Hausmeister time limit per test 1 second memory limit per test 256 megabytes input s ...

  3. Codeforces812C Sagheer and Nubian Market 2017-06-02 20:39 153人阅读 评论(0) 收藏

    C. Sagheer and Nubian Market time limit per test 2 seconds memory limit per test 256 megabytes input ...

  4. hadoop调优之一:概述 分类: A1_HADOOP B3_LINUX 2015-03-13 20:51 395人阅读 评论(0) 收藏

    hadoop集群性能低下的常见原因 (一)硬件环境 1.CPU/内存不足,或未充分利用 2.网络原因 3.磁盘原因 (二)map任务原因 1.输入文件中小文件过多,导致多次启动和停止JVM进程.可以设 ...

  5. Self Numbers 分类: POJ 2015-06-12 20:07 14人阅读 评论(0) 收藏

    Self Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 22101   Accepted: 12429 De ...

  6. Debian自启动知识 2015-03-31 20:23 79人阅读 评论(0) 收藏

    Debian6添加了insserv用来代替update-rc.d.update-rc.d 就不多做介绍. Debian6里边要添加一个自动启动的服务需要先将启动脚本放在/etc/init.d,然后使用 ...

  7. UI基础:UIView(window,frame,UIColor,CGPoint,alpha,CGRect等) 分类: iOS学习-UI 2015-06-30 20:01 119人阅读 评论(0) 收藏

    UIView 视图类,视图都是UIView或者UIView子类 UIWindow 窗口类,用于展示视图,视图一定要添加window才能显示 注意:一般来说,一个应用只有一个window 创建一个UIW ...

  8. OC基础:OC 基本数据类型与对象之间的转换方法 分类: ios学习 OC 2015-06-18 20:01 11人阅读 评论(0) 收藏

    1.Foundation框架中提供了很多的集合类如:NSArray,NSMutableArray,NSSet,NSMutableSet,NSDictionary,NSMutableDictionary ...

  9. ZOJ2748 Free Kick 2017-04-18 20:40 40人阅读 评论(0) 收藏

    Free Kick Time Limit: 2 Seconds      Memory Limit: 65536 KB In a soccer game, a direct free kick is ...

随机推荐

  1. Soa思想分布式服务webservice WCF

    什么是分布式事务 分布式事务就是指事务的参与者.支持事务的服务器.资源服务器以及事务管理器分别位于不同的分布式系统的不同节点之上.以上是百度百科的解释,简单的说,就是一次大的操作由不同的小操作组成,这 ...

  2. URLEncoder.encode转译后“空格”变“加号”的问题的解决方案

    我用dst_fname=URLEncoder.encode(dst_fname);对字符串dst_fname进行编码,但是发现空格全部都变成了加号,我们提需求的傻B非得要空格的,但是不编码有很多非常特 ...

  3. N! java

    import java.util.*; import java.math.*; public class Num2{ public static void main(String args[]){ B ...

  4. mysql if--then--else --endif 问题

    if 0 =resultValue then set @m = 2; else set @m =1; end if if 0 =resultValue then set @m = 2; else se ...

  5. [Robot Framework] 学习资料

    https://www.cnblogs.com/pachongshangdexuebi/category/981644.html Robot Framework学习笔记(一)------环境搭建 Ro ...

  6. Spring 属性注入(四)属性键值对 - PropertyValue

    Spring 属性注入(四)属性键值对 - PropertyValue Spring 系列目录(https://www.cnblogs.com/binarylei/p/10117436.html) P ...

  7. 人类及其他物种基因组DNA之问

    问题1 : 不同人类个体的基因组长度总长是不是一样,如果不一样,那么人类基因组长度排序和范围区间是如何控制的?最短是多少,最长是多少?如果一样,如何理解基因的插入与缺失,INDEL等现象,如何平衡的呢 ...

  8. Python内置的subprocess.Popen对象

    具体内容参见:https://docs.python.org/3/library/subprocess.html 大概来说,就是可以对应输入的命令产生一个进程,该进程实例内置如下方法. |  comm ...

  9. js网页上画图

    保存 1.d3.js  (http://www.d3.org/)使用svg技术,展示大数据量,动态效果很好,但是API暴露的不好,得靠自己摸索. 2.http://raphaeljs.com/refe ...

  10. hdu-6058 Kanade's sum

    题意:略 思路:要我们求每个区间第K大数之和,其实可以转换为求多少个区间的第K大数是X,然后我们在求和就好了. 那么我们可以从小到大枚举所有可能成为第K大的数.为什么从小到大呢? 因为从小到大我们就略 ...