from itertools import combinations
from copy import copy
def main():
N = int(input())
poses = [list(map(int, x)) for x in zip(*[input().strip().split() for _ in range(3)])]
for from_pos, to_pos in combinations(poses, 2):
ghost_pos = copy(from_pos)
x_dir = 1 if to_pos[0] - ghost_pos[0] > 0 else (0 if to_pos[0] - ghost_pos[0] == 0 else -1)
y_dir = 1 if to_pos[1] - ghost_pos[1] > 0 else (0 if to_pos[1] - ghost_pos[1] == 0 else -1)
z_dir = 1 if to_pos[2] - ghost_pos[2] > 0 else (0 if to_pos[2] - ghost_pos[2] == 0 else -1)
while ghost_pos != to_pos:
if ghost_pos[0] != to_pos[0] and [ghost_pos[0]+x_dir, ghost_pos[1], ghost_pos[2]] in poses:
ghost_pos[0] += x_dir
elif ghost_pos[1] != to_pos[1] and [ghost_pos[0], ghost_pos[1]+y_dir, ghost_pos[2]] in poses:
ghost_pos[1] += y_dir
elif ghost_pos[2] != to_pos[2] and [ghost_pos[0], ghost_pos[1], ghost_pos[2]+z_dir] in poses:
ghost_pos[2] += z_dir
else:
print("NO")
return
print("YES")
main()
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 19ms | 3376 KiB | ||||
2 | Accepted | 18ms | 3364 KiB | ||||
3 | Accepted | 18ms | 3384 KiB | ||||
subtask2 | 18/18 | ||||||
4 | Accepted | 20ms | 3340 KiB | ||||
5 | Accepted | 18ms | 3568 KiB | ||||
6 | Accepted | 578ms | 3392 KiB | ||||
7 | Accepted | 86ms | 3384 KiB | ||||
8 | Accepted | 65ms | 3384 KiB | ||||
9 | Accepted | 17ms | 3384 KiB | ||||
10 | Accepted | 94ms | 3352 KiB | ||||
11 | Accepted | 75ms | 3384 KiB | ||||
12 | Accepted | 17ms | 3400 KiB | ||||
13 | Accepted | 68ms | 3308 KiB | ||||
subtask3 | 0/19 | ||||||
14 | Accepted | 29ms | 5936 KiB | ||||
15 | Time limit exceeded | 3.094s | 3340 KiB | ||||
16 | Accepted | 79ms | 5300 KiB | ||||
17 | Time limit exceeded | 3.094s | 5936 KiB | ||||
18 | Time limit exceeded | 3.089s | 5944 KiB | ||||
19 | Time limit exceeded | 3.079s | 5948 KiB | ||||
20 | Accepted | 43ms | 3496 KiB | ||||
21 | Accepted | 28ms | 4772 KiB | ||||
22 | Time limit exceeded | 3.082s | 5936 KiB | ||||
23 | Time limit exceeded | 3.101s | 6088 KiB | ||||
24 | Time limit exceeded | 3.099s | 5944 KiB | ||||
25 | Time limit exceeded | 3.088s | 5984 KiB | ||||
26 | Accepted | 54ms | 3384 KiB | ||||
subtask4 | 0/24 | ||||||
27 | Accepted | 187ms | 37260 KiB | ||||
28 | Time limit exceeded | 3.092s | 3896 KiB | ||||
29 | Time limit exceeded | 3.092s | 38600 KiB | ||||
30 | Time limit exceeded | 3.092s | 39900 KiB | ||||
31 | Time limit exceeded | 3.082s | 39200 KiB | ||||
32 | Time limit exceeded | 3.078s | 39192 KiB | ||||
33 | Time limit exceeded | 3.099s | 3896 KiB | ||||
34 | Time limit exceeded | 3.099s | 39132 KiB | ||||
35 | Time limit exceeded | 3.091s | 39276 KiB | ||||
36 | Time limit exceeded | 3.088s | 40368 KiB | ||||
37 | Time limit exceeded | 3.101s | 39200 KiB | ||||
38 | Time limit exceeded | 3.098s | 39208 KiB | ||||
39 | Time limit exceeded | 3.086s | 3640 KiB | ||||
subtask5 | 0/22 | ||||||
40 | Accepted | 192ms | 37164 KiB | ||||
41 | Time limit exceeded | 3.082s | 3364 KiB | ||||
42 | Time limit exceeded | 3.082s | 13904 KiB | ||||
43 | Time limit exceeded | 3.082s | 38384 KiB | ||||
44 | Time limit exceeded | 3.088s | 38980 KiB | ||||
45 | Time limit exceeded | 3.088s | 38848 KiB | ||||
46 | Accepted | 43ms | 3580 KiB | ||||
47 | Accepted | 32ms | 3384 KiB | ||||
48 | Time limit exceeded | 3.089s | 10296 KiB | ||||
49 | Time limit exceeded | 3.101s | 34972 KiB | ||||
50 | Time limit exceeded | 3.095s | 38948 KiB | ||||
51 | Time limit exceeded | 3.088s | 38752 KiB | ||||
52 | Time limit exceeded | 3.089s | 39004 KiB | ||||
53 | Accepted | 243ms | 3456 KiB | ||||
subtask6 | 0/17 | ||||||
54 | Accepted | 225ms | 49836 KiB | ||||
55 | Time limit exceeded | 3.076s | 49880 KiB | ||||
56 | Time limit exceeded | 3.078s | 49828 KiB | ||||
57 | Accepted | 1.401s | 50292 KiB | ||||
58 | Time limit exceeded | 3.085s | 49904 KiB | ||||
59 | Time limit exceeded | 3.082s | 50156 KiB | ||||
60 | Time limit exceeded | 3.088s | 49684 KiB | ||||
61 | Time limit exceeded | 3.089s | 49876 KiB | ||||
62 | Time limit exceeded | 3.078s | 49632 KiB | ||||
63 | Time limit exceeded | 3.085s | 49372 KiB | ||||
64 | Time limit exceeded | 3.081s | 49748 KiB | ||||
65 | Time limit exceeded | 3.082s | 49948 KiB | ||||
66 | Time limit exceeded | 3.085s | 30476 KiB |