115592024-10-26 22:11:46balintPac-Manpython3Time limit exceeded 18/1003.101s45272 KiB
from itertools import combinations

def main():
    N = int(input())
    poses = {tuple(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 = list(from_pos)

        x_dir = (to_pos[0] > ghost_pos[0]) - (to_pos[0] < ghost_pos[0])
        y_dir = (to_pos[1] > ghost_pos[1]) - (to_pos[1] < ghost_pos[1])
        z_dir = (to_pos[2] > ghost_pos[2]) - (to_pos[2] < ghost_pos[2])
        while ghost_pos != list(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
1Accepted17ms3124 KiB
2Accepted17ms3116 KiB
3Accepted17ms3128 KiB
subtask218/18
4Accepted17ms3096 KiB
5Accepted16ms3112 KiB
6Accepted97ms3244 KiB
7Accepted32ms3240 KiB
8Accepted28ms3120 KiB
9Accepted17ms3240 KiB
10Accepted34ms3264 KiB
11Accepted28ms3128 KiB
12Accepted16ms3128 KiB
13Accepted29ms3128 KiB
subtask30/19
14Accepted27ms5720 KiB
15Accepted414ms3204 KiB
16Accepted29ms5432 KiB
17Accepted32ms5816 KiB
18Time limit exceeded3.085s5812 KiB
19Time limit exceeded3.099s5912 KiB
20Accepted16ms3128 KiB
21Accepted20ms4384 KiB
22Accepted150ms5812 KiB
23Time limit exceeded3.029s6144 KiB
24Time limit exceeded3.085s5912 KiB
25Accepted57ms5912 KiB
26Accepted30ms3128 KiB
subtask40/24
27Accepted171ms33536 KiB
28Time limit exceeded3.084s3892 KiB
29Time limit exceeded3.085s34968 KiB
30Time limit exceeded3.085s35576 KiB
31Time limit exceeded3.082s35352 KiB
32Time limit exceeded3.094s35340 KiB
33Accepted783ms3640 KiB
34Time limit exceeded3.101s34812 KiB
35Time limit exceeded3.088s35352 KiB
36Time limit exceeded3.089s35352 KiB
37Time limit exceeded3.088s35100 KiB
38Time limit exceeded3.101s35348 KiB
39Time limit exceeded3.085s3384 KiB
subtask50/22
40Accepted188ms33820 KiB
41Accepted488ms3128 KiB
42Accepted64ms13200 KiB
43Accepted162ms35280 KiB
44Time limit exceeded3.091s35856 KiB
45Time limit exceeded3.088s35856 KiB
46Accepted17ms3132 KiB
47Accepted17ms3128 KiB
48Accepted50ms11104 KiB
49Time limit exceeded3.089s33320 KiB
50Accepted1.838s35856 KiB
51Time limit exceeded3.075s35900 KiB
52Accepted1.358s35852 KiB
53Accepted32ms3128 KiB
subtask60/17
54Accepted230ms45232 KiB
55Time limit exceeded3.085s45228 KiB
56Accepted230ms45260 KiB
57Accepted194ms45140 KiB
58Time limit exceeded3.085s45272 KiB
59Time limit exceeded3.091s45260 KiB
60Accepted356ms45232 KiB
61Accepted216ms45240 KiB
62Accepted212ms45272 KiB
63Time limit exceeded3.085s45040 KiB
64Time limit exceeded3.089s44908 KiB
65Accepted2.203s45156 KiB
66Time limit exceeded3.101s26304 KiB