Sagheer and Crossroads

本文介绍了一个基于CodeForces-812A的问题,该问题探讨了在四路交叉口如何通过监测交通信号灯的状态来预测可能发生的行人与车辆事故。文章提供了详细的AC代码,用于检测当人行横道为绿灯时,是否有任何车辆车道也为绿色,从而判断是否存在事故风险。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 Sagheer and Crossroads

 CodeForces - 812A 

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 3 can 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.

题目大意:在人行道为绿灯时其他经过这条人行道的车道必须为红灯,分开讨论即可

AC代码

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <utility>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define lep(i,l,r) for(int i=l;i>=r;i--)
#define ms(arr) memset(arr,0,sizeof(arr))
//priority_queue<int,vector<int> ,greater<int> >q;
const int maxn = (int)1e5 + 5;
const ll mod = 1e9+7;
int mapp[10][10];
int main() 
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(0),cin.tie(0);
    bool j=false;
    rep(i,1,4) {
    	rep(j,1,4) {
    		cin>>mapp[i][j];
    	}
    }
    int a1,a2,a3,a4;
    a1=mapp[1][1]+mapp[1][2]+mapp[1][3]+mapp[4][3]+mapp[3][2]+mapp[2][1];
    a2=mapp[2][1]+mapp[2][2]+mapp[2][3]+mapp[1][3]+mapp[4][2]+mapp[3][1];
    a3=mapp[3][1]+mapp[3][2]+mapp[3][3]+mapp[2][3]+mapp[1][2]+mapp[4][1];
    a4=mapp[4][1]+mapp[4][2]+mapp[4][3]+mapp[3][3]+mapp[2][2]+mapp[1][1];
    if(mapp[1][4]==1&&a1!=0)
    	j=true;
    if(mapp[2][4]==1&&a2!=0)
    	j=true;
    if(mapp[3][4]==1&&a3!=0)
    	j=true;
    if(mapp[4][4]==1&&a4!=0)
    	j=true;
    if(j)
    	cout<<"YES"<<endl;
    else
    	cout<<"NO"<<endl;
    return 0;
}

 

内容概要:本文档为《400_IB Specification Vol 2-Release-2.0-Final-2025-07-31.pdf》,主要描述了InfiniBand架构2.0版本的物理层规范。文档详细规定了链路初始化、配置与训练流程,包括但不限于传输序列(TS1、TS2、TS3)、链路去偏斜、波特率、前向纠错(FEC)支持、链路速度协商及扩展速度选项等。此外,还介绍了链路状态机的不同状态(如禁用、轮询、配置等),以及各状态下应遵循的规则和命令。针对不同数据速率(从SDR到XDR)的链路格式化规则也有详细说明,确保数据包格式和控制符号在多条物理通道上的一致性和正确性。文档还涵盖了链路性能监控和错误检测机制。 适用人群:适用于从事网络硬件设计、开发及维护的技术人员,尤其是那些需要深入了解InfiniBand物理层细节的专业人士。 使用场景及目标:① 设计和实现支持多种数据速率和编码方式的InfiniBand设备;② 开发链路初始化和训练算法,确保链路两端设备能够正确配置并优化通信质量;③ 实现链路性能监控和错误检测,提高系统的可靠性和稳定性。 其他说明:本文档属于InfiniBand贸易协会所有,为专有信息,仅供内部参考和技术交流使用。文档内容详尽,对于理解和实施InfiniBand接口具有重要指导意义。读者应结合相关背景资料进行学习,以确保正确理解和应用规范中的各项技术要求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值