codeforces 812A Sagheer and Crossroads

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 0 0 1
0 1 0 0
0 0 1 0
0 0 0 1
output
YES
input
0 1 1 0
1 0 1 0
1 1 0 0
0 0 0 1
output
NO
input
1 0 0 0
0 0 0 1
0 0 0 0
1 0 1 0
output
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.


题目意思比题目本身难系列......

题目大意:给你左直右三个方向和行人的灯,0表示没亮,1表示亮,看他会不会被撞

如果行人方向的那条路有灯亮就肯定会被撞,其他的路按照常识判断即可

#include<iostream>
#include<cstdio>
using namespace std;
int main(){
	int l[10],s[10],r[10],p[10];
	for(int i=1;i<=4;i++){
		scanf("%d%d%d%d",&l[i],&s[i],&r[i],&p[i]);
	}
	bool flag=false;
	if(p[1]==1&&((l[1]==1||s[1]==1||r[1]==1)||(l[2]==1||s[3]==1||r[4]==1))) flag=true;
	if(p[2]==1&&((l[2]==1||s[2]==1||r[2]==1)||(l[3]==1||s[4]==1||r[1]==1))) flag=true;
	if(p[3]==1&&((l[3]==1||s[3]==1||r[3]==1)||(l[4]==1||s[1]==1||r[2]==1))) flag=true;
	if(p[4]==1&&((l[4]==1||s[4]==1||r[4]==1)||(l[1]==1||s[2]==1||r[3]==1))) flag=true;
	if(flag) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值