-
Notifications
You must be signed in to change notification settings - Fork 0
/
B.cpp
120 lines (45 loc) · 1.51 KB
/
B.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pl;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
typedef vector<vpl> vvpl;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<vpi> vvpi;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define eb emplace_back
#define all(c) (c.begin()) (c.end())
#define fi first
#define se second
// APPLES ARE TASTY YUM YUM YUM YUM
void solve() {
ll n, u, r, d, l; cin >> n >> u >> r >> d >> l;
for(int lmask = 0; lmask < 4; ++lmask) {
for(int rmask = 0; rmask < 4; ++rmask) {
int lcount = __builtin_popcount(lmask);
int rcount = __builtin_popcount(rmask);
int ucount = (lmask&1) + (rmask&1);
int dcount = lmask/2 + rmask/2;
if(ucount > u || n-2 + ucount < u) continue;
if(dcount > d || n-2 + dcount < d) continue;
if(lcount > l || n-2 + lcount < l) continue;
if(rcount > r || n-2 + rcount < r) continue;
cout << "YES" << '\n'; return;
}
}
cout << "NO" << '\n'; return;
}
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int t; cin >> t;
rep(i, t) {
solve();
}
return 0;
}