-
Notifications
You must be signed in to change notification settings - Fork 0
/
day7_1395A.cpp
59 lines (51 loc) · 960 Bytes
/
day7_1395A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* We can create a palindrome with chars [r, g, b, w] if there is less then equal to one of them is odd. if there is more then one of the numbers odd then we can't create palindrome.
Also we only need to check 2 times, because every time even becomes odd and odd becomes even.
*/
#include <bits/stdc++.h>
using namespace std;
int check(int r, int g, int b, int w) {
int odd = 0;
int even = 0;
if(r % 2 == 0)
even ++;
else
odd ++;
if(g % 2 == 0)
even ++;
else
odd ++;
if(b % 2 == 0)
even ++;
else
odd ++;
if(w % 2 == 0)
even ++;
else
odd ++;
return odd <= 1;
}
int main() {
int t;
cin >> t;
while(t --) {
int r, g, b, w;
cin >> r >> g >> b >> w;
int a = min(min(r, min(g, b)), 3);
for(int i = 0; i < a; i ++) {
if(check(r, g, b, w)) {
break;
} else {
r --;
g --;
b --;
w += 3;
}
}
if(check(r, g, b, w)) {
cout << "YES\n";
} else {
cout << "NO\n";
}
}
return 0;
}