#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define pii pair<int, int>
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifdef CB
freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
#endif
int N;
cin >> N;
vector<int> X(N), Y(N), Z(N);
for (int i = 0; i < N; i++) {
cin >> X[i];
}
for (int i = 0; i < N; i++) {
cin >> Y[i];
}
for (int i = 0; i < N; i++) {
cin >> Z[i];
}
set<tuple<int, int, int>> s;
for (int i = 0; i < N; i++) {
s.insert({X[i], Y[i], Z[i]});
}
for (int i = 0; i < N; i++) {
for (int j = i + 1; j < N; j++) {
if (X[i] < X[j] && s.count({X[i] + 1, Y[i], Z[i]})) {
continue;
}
if (X[i] > X[j] && s.count({X[i] - 1, Y[i], Z[i]})) {
continue;
}
if (Y[i] < Y[j] && s.count({X[i], Y[i] + 1, Z[i]})) {
continue;
}
if (Y[i] > Y[j] && s.count({X[i], Y[i] - 1, Z[i]})) {
continue;
}
if (Z[i] < Z[j] && s.count({X[i], Y[i], Z[i] + 1})) {
continue;
}
if (Z[i] > Z[j] && s.count({X[i], Y[i], Z[i] - 1})) {
continue;
}
goto bad;
}
}
cout << "YES" << '\n';
return 0;
bad:
cout << "NO" << '\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1824 KiB | ||||
2 | Accepted | 3ms | 2016 KiB | ||||
3 | Accepted | 3ms | 2248 KiB | ||||
subtask2 | 18/18 | ||||||
4 | Accepted | 3ms | 2488 KiB | ||||
5 | Accepted | 3ms | 2552 KiB | ||||
6 | Accepted | 3ms | 2756 KiB | ||||
7 | Accepted | 3ms | 2856 KiB | ||||
8 | Accepted | 3ms | 3072 KiB | ||||
9 | Accepted | 3ms | 3184 KiB | ||||
10 | Accepted | 3ms | 3412 KiB | ||||
11 | Accepted | 3ms | 3628 KiB | ||||
12 | Accepted | 3ms | 3712 KiB | ||||
13 | Accepted | 3ms | 3704 KiB | ||||
subtask3 | 19/19 | ||||||
14 | Accepted | 7ms | 5128 KiB | ||||
15 | Accepted | 3ms | 3832 KiB | ||||
16 | Accepted | 34ms | 4704 KiB | ||||
17 | Accepted | 14ms | 5264 KiB | ||||
18 | Accepted | 1.2s | 5220 KiB | ||||
19 | Accepted | 1.167s | 5212 KiB | ||||
20 | Accepted | 3ms | 4204 KiB | ||||
21 | Accepted | 41ms | 4752 KiB | ||||
22 | Accepted | 642ms | 5332 KiB | ||||
23 | Accepted | 28ms | 5404 KiB | ||||
24 | Accepted | 305ms | 5464 KiB | ||||
25 | Accepted | 41ms | 5480 KiB | ||||
26 | Accepted | 3ms | 4280 KiB | ||||
subtask4 | 0/24 | ||||||
27 | Accepted | 75ms | 21196 KiB | ||||
28 | Accepted | 96ms | 4864 KiB | ||||
29 | Time limit exceeded | 3.066s | 12348 KiB | ||||
30 | Time limit exceeded | 3.055s | 12032 KiB | ||||
31 | Time limit exceeded | 3.051s | 12180 KiB | ||||
32 | Time limit exceeded | 3.053s | 12176 KiB | ||||
33 | Accepted | 25ms | 4664 KiB | ||||
34 | Time limit exceeded | 3.101s | 12180 KiB | ||||
35 | Time limit exceeded | 3.101s | 12384 KiB | ||||
36 | Time limit exceeded | 3.019s | 12452 KiB | ||||
37 | Time limit exceeded | 3.039s | 12436 KiB | ||||
38 | Time limit exceeded | 3.055s | 12412 KiB | ||||
39 | Accepted | 14ms | 4656 KiB | ||||
subtask5 | 0/22 | ||||||
40 | Accepted | 78ms | 21636 KiB | ||||
41 | Accepted | 4ms | 4780 KiB | ||||
42 | Accepted | 558ms | 9672 KiB | ||||
43 | Accepted | 2.614s | 21924 KiB | ||||
44 | Time limit exceeded | 3.059s | 12672 KiB | ||||
45 | Time limit exceeded | 3.068s | 12864 KiB | ||||
46 | Accepted | 3ms | 4988 KiB | ||||
47 | Accepted | 3ms | 4972 KiB | ||||
48 | Accepted | 71ms | 8244 KiB | ||||
49 | Time limit exceeded | 3.059s | 11952 KiB | ||||
50 | Time limit exceeded | 3.055s | 12704 KiB | ||||
51 | Time limit exceeded | 3.052s | 12708 KiB | ||||
52 | Accepted | 1.253s | 22060 KiB | ||||
53 | Accepted | 3ms | 5004 KiB | ||||
subtask6 | 0/17 | ||||||
54 | Accepted | 83ms | 22052 KiB | ||||
55 | Time limit exceeded | 3.075s | 12824 KiB | ||||
56 | Accepted | 522ms | 22140 KiB | ||||
57 | Time limit exceeded | 3.058s | 13072 KiB | ||||
58 | Time limit exceeded | 3.073s | 12788 KiB | ||||
59 | Time limit exceeded | 3.073s | 12908 KiB | ||||
60 | Time limit exceeded | 3.055s | 12848 KiB | ||||
61 | Accepted | 551ms | 22064 KiB | ||||
62 | Accepted | 773ms | 22236 KiB | ||||
63 | Time limit exceeded | 3.052s | 12776 KiB | ||||
64 | Time limit exceeded | 3.066s | 12980 KiB | ||||
65 | Accepted | 546ms | 22376 KiB | ||||
66 | Time limit exceeded | 3.042s | 12980 KiB |