Codeforces 812 A Sagheer and Crossroads
题目链接:http://codeforces.com/contest/812/problem/A
题意:其实就是判断行人通过时,该路上有没有汽车通过,用常识去写就好了,输入的其实分别是4条路向左向右向前以及行人的是否可以通行的信号,判断是否会发生事故
1 #include <iostream> 2 #include <cstring> 3 #include <string> 4 #include <vector> 5 #include <queue> 6 #include <map> 7 #include <set> 8 #include <algorithm> 9 #define N 110 10 #define inf 0x3f3f3f3f 11 #define LL long long 12 using namespace std; 13 int l[4], s[4], r[4], p[4]; 14 int main() { 15 cin.sync_with_stdio(false); 16 int flag = 0; 17 for (int i = 0; i < 4; i++) { 18 cin >> l[i] >> s[i] >> r[i] >> p[i]; 19 if (p[i] == 1) { 20 if (l[i] == 1 || s[i] == 1 || r[i] == 1) { 21 cout << "YES" << endl; 22 return 0; 23 } 24 } 25 } 26 for (int i = 0; i < 4; i++) { 27 if (r[i] == 1 && p[(i + 1) % 4] == 1) { 28 cout << "YES" << endl; 29 return 0; 30 } 31 } 32 for (int i = 0; i < 4; i++) { 33 if (s[i] == 1 && p[(i + 2) % 4] == 1) { 34 cout << "YES" << endl; 35 return 0; 36 } 37 } 38 for (int i = 0; i < 4; i++) { 39 if (l[i] == 1 && p[(i + 3) % 4] == 1) { 40 cout << "YES" << endl; 41 return 0; 42 } 43 } 44 cout << "NO" << endl; 45 return 0; 46 }
2017-06-02 09:09:19