115602024-10-26 22:19:48balintPac-Manpython3Time limit exceeded 18/1003.101s45404 KiB
from itertools import combinations

def main():
    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):
            moved = False

            for axis in range(3):
                if ghost_pos[axis] != to_pos[axis]:
                    next_pos = ghost_pos[:]
                    next_pos[axis] += (x_dir if axis == 0 else (y_dir if axis == 1 else z_dir))
                    if tuple(next_pos) in poses:
                        ghost_pos[axis] += (x_dir if axis == 0 else (y_dir if axis == 1 else z_dir))
                        moved = True
                        break

            if not moved: 
                print("NO")
                return 

    print("YES")

main()
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted17ms3128 KiB
2Accepted16ms3128 KiB
3Accepted16ms3128 KiB
subtask218/18
4Accepted17ms3248 KiB
5Accepted17ms3256 KiB
6Accepted171ms3260 KiB
7Accepted46ms3260 KiB
8Accepted39ms3216 KiB
9Accepted17ms3132 KiB
10Accepted46ms3128 KiB
11Accepted37ms3264 KiB
12Accepted17ms3064 KiB
13Accepted41ms3128 KiB
subtask30/19
14Accepted28ms5688 KiB
15Accepted741ms3272 KiB
16Accepted37ms5428 KiB
17Accepted37ms5820 KiB
18Time limit exceeded3.081s5812 KiB
19Time limit exceeded3.099s5896 KiB
20Accepted17ms3128 KiB
21Accepted23ms4408 KiB
22Accepted263ms5812 KiB
23Time limit exceeded3.085s5912 KiB
24Time limit exceeded3.085s5912 KiB
25Accepted83ms5912 KiB
26Accepted46ms3212 KiB
subtask40/24
27Accepted185ms33200 KiB
28Time limit exceeded3.084s3904 KiB
29Time limit exceeded3.085s34980 KiB
30Time limit exceeded3.085s35748 KiB
31Time limit exceeded3.091s35500 KiB
32Time limit exceeded3.082s35132 KiB
33Accepted1.338s3640 KiB
34Time limit exceeded3.085s34724 KiB
35Time limit exceeded3.092s35328 KiB
36Time limit exceeded3.082s35184 KiB
37Time limit exceeded3.084s35496 KiB
38Time limit exceeded3.086s35340 KiB
39Time limit exceeded3.078s3404 KiB
subtask50/22
40Accepted180ms33844 KiB
41Accepted904ms3128 KiB
42Accepted57ms13192 KiB
43Accepted166ms34832 KiB
44Time limit exceeded3.088s35884 KiB
45Time limit exceeded3.088s35856 KiB
46Accepted17ms3128 KiB
47Accepted17ms3256 KiB
48Accepted50ms11324 KiB
49Time limit exceeded3.086s33320 KiB
50Time limit exceeded3.092s35880 KiB
51Time limit exceeded3.088s35884 KiB
52Accepted2.354s35868 KiB
53Accepted46ms3128 KiB
subtask60/17
54Accepted200ms44988 KiB
55Time limit exceeded3.092s45404 KiB
56Accepted228ms45260 KiB
57Accepted201ms44580 KiB
58Time limit exceeded3.101s45276 KiB
59Time limit exceeded3.101s44676 KiB
60Accepted342ms45392 KiB
61Accepted188ms45284 KiB
62Accepted214ms45272 KiB
63Time limit exceeded3.078s44940 KiB
64Time limit exceeded3.091s44972 KiB
65Time limit exceeded3.088s44564 KiB
66Time limit exceeded3.088s26528 KiB