115582024-10-26 22:01:41balintPac-Manpython3Time limit exceeded 18/1003.101s50292 KiB
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()
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted19ms3376 KiB
2Accepted18ms3364 KiB
3Accepted18ms3384 KiB
subtask218/18
4Accepted20ms3340 KiB
5Accepted18ms3568 KiB
6Accepted578ms3392 KiB
7Accepted86ms3384 KiB
8Accepted65ms3384 KiB
9Accepted17ms3384 KiB
10Accepted94ms3352 KiB
11Accepted75ms3384 KiB
12Accepted17ms3400 KiB
13Accepted68ms3308 KiB
subtask30/19
14Accepted29ms5936 KiB
15Time limit exceeded3.094s3340 KiB
16Accepted79ms5300 KiB
17Time limit exceeded3.094s5936 KiB
18Time limit exceeded3.089s5944 KiB
19Time limit exceeded3.079s5948 KiB
20Accepted43ms3496 KiB
21Accepted28ms4772 KiB
22Time limit exceeded3.082s5936 KiB
23Time limit exceeded3.101s6088 KiB
24Time limit exceeded3.099s5944 KiB
25Time limit exceeded3.088s5984 KiB
26Accepted54ms3384 KiB
subtask40/24
27Accepted187ms37260 KiB
28Time limit exceeded3.092s3896 KiB
29Time limit exceeded3.092s38600 KiB
30Time limit exceeded3.092s39900 KiB
31Time limit exceeded3.082s39200 KiB
32Time limit exceeded3.078s39192 KiB
33Time limit exceeded3.099s3896 KiB
34Time limit exceeded3.099s39132 KiB
35Time limit exceeded3.091s39276 KiB
36Time limit exceeded3.088s40368 KiB
37Time limit exceeded3.101s39200 KiB
38Time limit exceeded3.098s39208 KiB
39Time limit exceeded3.086s3640 KiB
subtask50/22
40Accepted192ms37164 KiB
41Time limit exceeded3.082s3364 KiB
42Time limit exceeded3.082s13904 KiB
43Time limit exceeded3.082s38384 KiB
44Time limit exceeded3.088s38980 KiB
45Time limit exceeded3.088s38848 KiB
46Accepted43ms3580 KiB
47Accepted32ms3384 KiB
48Time limit exceeded3.089s10296 KiB
49Time limit exceeded3.101s34972 KiB
50Time limit exceeded3.095s38948 KiB
51Time limit exceeded3.088s38752 KiB
52Time limit exceeded3.089s39004 KiB
53Accepted243ms3456 KiB
subtask60/17
54Accepted225ms49836 KiB
55Time limit exceeded3.076s49880 KiB
56Time limit exceeded3.078s49828 KiB
57Accepted1.401s50292 KiB
58Time limit exceeded3.085s49904 KiB
59Time limit exceeded3.082s50156 KiB
60Time limit exceeded3.088s49684 KiB
61Time limit exceeded3.089s49876 KiB
62Time limit exceeded3.078s49632 KiB
63Time limit exceeded3.085s49372 KiB
64Time limit exceeded3.081s49748 KiB
65Time limit exceeded3.082s49948 KiB
66Time limit exceeded3.085s30476 KiB