結果

問題 No.759 悪くない忘年会にしような!
ユーザー tktk_snsntktk_snsn
提出日時 2022-05-12 12:27:11
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 1,472 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 151,744 KB
最終ジャッジ日時 2023-09-27 11:25:15
合計ジャッジ時間 19,465 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
71,540 KB
testcase_01 AC 101 ms
71,672 KB
testcase_02 AC 96 ms
71,668 KB
testcase_03 AC 98 ms
71,708 KB
testcase_04 WA -
testcase_05 AC 95 ms
71,672 KB
testcase_06 AC 100 ms
71,528 KB
testcase_07 AC 94 ms
71,520 KB
testcase_08 AC 100 ms
71,668 KB
testcase_09 WA -
testcase_10 AC 93 ms
71,472 KB
testcase_11 AC 95 ms
71,752 KB
testcase_12 AC 99 ms
71,276 KB
testcase_13 AC 100 ms
71,672 KB
testcase_14 AC 97 ms
71,724 KB
testcase_15 AC 97 ms
71,568 KB
testcase_16 AC 101 ms
71,668 KB
testcase_17 AC 92 ms
71,732 KB
testcase_18 AC 92 ms
71,728 KB
testcase_19 AC 92 ms
71,580 KB
testcase_20 AC 103 ms
71,416 KB
testcase_21 AC 98 ms
71,736 KB
testcase_22 AC 100 ms
71,540 KB
testcase_23 WA -
testcase_24 AC 95 ms
71,672 KB
testcase_25 AC 98 ms
71,556 KB
testcase_26 AC 102 ms
71,684 KB
testcase_27 AC 101 ms
71,668 KB
testcase_28 WA -
testcase_29 AC 99 ms
71,528 KB
testcase_30 AC 100 ms
71,864 KB
testcase_31 WA -
testcase_32 AC 100 ms
71,400 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 AC 479 ms
151,320 KB
testcase_64 AC 481 ms
151,140 KB
testcase_65 AC 432 ms
138,852 KB
testcase_66 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


N = int(input())
PQR = tuple(tuple(map(int, input().split())) for _ in range(N))
P, Q, R = zip(*PQR)

ptoi = {p: i for i, p in enumerate(sorted(set(P)))}
M = len(ptoi)
d = [[] for _ in range(M)]
for i, (p, q, r) in enumerate(PQR, 1):
    d[ptoi[p]].append((q, r, i))

for i in range(M):
    stack = []
    d[i].sort()
    for q, r, j in d[i]:
        if stack and stack[-1][1] <= r:
            stack.pop()
        stack.append((q, r, j))
    d[i] = stack
    d[i].reverse()


def merge(i, j):
    F = d[i]
    G = d[j]
    stack = []
    pri = []

    def insert(x):
        while stack:
            if pri[-1] == 0 and stack[-1][1] <= x[1]:
                stack.pop()
                pri.pop()
                continue
            break
        stack.append(x)
        pri.append(1)

    while F and G:
        if F[-1][0] <= G[-1][0]:
            stack.append(F.pop())
            pri.append(0)
        else:
            insert(G.pop())
    while F:
        stack.append(F.pop())
        pri.append(0)
    while G:
        insert(G.pop())

    stack.reverse()
    d[i] = stack


que = deque(range(M))
while len(que) > 1:
    a = que.popleft()
    b = que.popleft()
    if a > b:
        que.append(a)
        que.appendleft(b)
        continue
    merge(a, b)
    que.append(a)


ans = []
for _, _, i in d[0]:
    ans.append(i)
ans.sort()
print(*ans, sep="\n")
0