115662024-10-27 00:35:01balintPac-Manpypy3Time limit exceeded 18/1003.108s63284 KiB
from itertools import combinations
import sys
# sys.stdin.read().strip().splitlines()
def main():
    lines = sys.stdin.read().strip().splitlines()

    poses = {tuple(map(int, x)) for x in zip(*[map(int, lines[1].split()), map(int, lines[2].split()), map(int, lines[3].split())])}

    for from_pos, to_pos in combinations(poses, 2):
        ghost_pos = list(from_pos)

        dirs = ((to_pos[0] > ghost_pos[0]) - (to_pos[0] < ghost_pos[0]),
                (to_pos[1] > ghost_pos[1]) - (to_pos[1] < ghost_pos[1]),
                (to_pos[2] > ghost_pos[2]) - (to_pos[2] < ghost_pos[2]))
        # poses_went_throught = []
        while ghost_pos != list(to_pos):
            for axis in range(3):
                if ghost_pos[axis] != to_pos[axis]:
                    next_pos = ghost_pos[:]
                    next_pos[axis] += dirs[axis]
                    if tuple(next_pos) in poses:
                        ghost_pos[axis] += dirs[axis]
                        # poses_went_throught.append(ghost_pos[axis])
                        break

            else:
                sys.stdout.write('NO')
                return 
    sys.stdout.write('YES')

main()
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted41ms19696 KiB
2Accepted41ms19660 KiB
3Accepted45ms19888 KiB
subtask218/18
4Accepted41ms19760 KiB
5Accepted45ms19764 KiB
6Accepted173ms22920 KiB
7Accepted125ms22064 KiB
8Accepted109ms22508 KiB
9Accepted46ms19692 KiB
10Accepted120ms22508 KiB
11Accepted137ms22508 KiB
12Accepted46ms21224 KiB
13Accepted68ms21740 KiB
subtask30/19
14Accepted72ms23632 KiB
15Accepted456ms22164 KiB
16Accepted61ms22900 KiB
17Accepted615ms24588 KiB
18Time limit exceeded3.091s26168 KiB
19Time limit exceeded3.102s25724 KiB
20Accepted70ms21992 KiB
21Accepted59ms23020 KiB
22Accepted384ms25068 KiB
23Accepted2.763s25780 KiB
24Time limit exceeded3.095s26348 KiB
25Accepted165ms24156 KiB
26Accepted72ms21740 KiB
subtask40/24
27Accepted282ms61932 KiB
28Time limit exceeded3.088s24252 KiB
29Time limit exceeded3.092s62312 KiB
30Time limit exceeded3.092s62320 KiB
31Time limit exceeded3.098s62428 KiB
32Time limit exceeded3.096s62420 KiB
33Accepted246ms23040 KiB
34Time limit exceeded3.107s62436 KiB
35Time limit exceeded3.096s62652 KiB
36Time limit exceeded3.089s62424 KiB
37Time limit exceeded3.091s62420 KiB
38Time limit exceeded3.107s62508 KiB
39Time limit exceeded3.092s22500 KiB
subtask50/22
40Accepted256ms61724 KiB
41Accepted541ms22380 KiB
42Accepted187ms32548 KiB
43Accepted270ms61076 KiB
44Time limit exceeded3.088s62320 KiB
45Time limit exceeded3.085s62412 KiB
46Accepted70ms22252 KiB
47Accepted63ms21740 KiB
48Accepted605ms29164 KiB
49Time limit exceeded3.092s58284 KiB
50Accepted1.689s61936 KiB
51Time limit exceeded3.092s62340 KiB
52Accepted1.263s61896 KiB
53Accepted104ms21740 KiB
subtask60/17
54Accepted268ms62760 KiB
55Time limit exceeded3.078s63212 KiB
56Accepted300ms62768 KiB
57Accepted300ms62584 KiB
58Time limit exceeded3.085s63156 KiB
59Time limit exceeded3.105s63284 KiB
60Accepted533ms62932 KiB
61Accepted270ms62844 KiB
62Accepted277ms62596 KiB
63Time limit exceeded3.088s62944 KiB
64Time limit exceeded3.092s63236 KiB
65Accepted1.09s62648 KiB
66Time limit exceeded3.108s62200 KiB