1. 程式人生 > >Codeforces Round #417 (Div. 2)-A. Sagheer and Crossroad

Codeforces Round #417 (Div. 2)-A. Sagheer and Crossroad

sca \n ret name nbsp style can turn ros

【題意概述】

   在一個十字路口 ,給定紅綠燈的情況, 按逆時針方向一次給出各個路口的左轉,直行,右轉,以及行人車道,判斷汽車是否有可能撞到行人
    

【題目分析】

  需要在邏輯上清晰,只需要把所有情況列出來即可

【AC】

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 
 4 int main() {
 5     int light[10][10];
 6     
 7     
 8     for(int i = 1; i <= 4; i++)
 9         for(int j = 1; j <= 4
; j++) 10 scanf("%d",&light[i][j]); 11 int ans = false; 12 if(light[1][4]) { 13 if(light[1][1] || light[1][2] || light[1][3] || light[2][1] || light[3][2] || light[4][3]) 14 ans = true; 15 } if(light[2][4]) { 16 if(light[2][1] || light[2
][2] || light[2][3] || light[1][3] || light[3][1] || light[4][2]) 17 ans = true; 18 } if(light[3][4]) { 19 if(light[3][1] || light[3][2] || light[3][3] || light[2][3] || light[1][2] || light[4][1]) 20 ans = true; 21 } if(light[4][4]) { 22 if(light[4
][1] || light[4][2] || light[4][3] || light[3][3] || light[2][2] || light[1][1]) 23 ans = true; 24 } 25 if(ans) 26 printf("YES\n"); 27 else 28 printf("NO\n"); 29 return 0; 30 }

Codeforces Round #417 (Div. 2)-A. Sagheer and Crossroad