結果

問題 No.759 悪くない忘年会にしような!
ユーザー tktk_snsntktk_snsn
提出日時 2022-05-12 12:46:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,586 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 87,296 KB
実行使用メモリ 154,152 KB
最終ジャッジ日時 2023-09-27 11:51:36
合計ジャッジ時間 14,270 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,868 KB
testcase_01 AC 78 ms
71,744 KB
testcase_02 AC 73 ms
71,572 KB
testcase_03 AC 72 ms
71,704 KB
testcase_04 WA -
testcase_05 AC 72 ms
71,648 KB
testcase_06 AC 70 ms
71,768 KB
testcase_07 AC 73 ms
71,640 KB
testcase_08 AC 72 ms
71,748 KB
testcase_09 WA -
testcase_10 AC 72 ms
71,744 KB
testcase_11 AC 72 ms
71,644 KB
testcase_12 AC 73 ms
71,572 KB
testcase_13 AC 77 ms
71,624 KB
testcase_14 AC 73 ms
71,748 KB
testcase_15 AC 75 ms
71,880 KB
testcase_16 AC 76 ms
71,368 KB
testcase_17 AC 73 ms
71,832 KB
testcase_18 AC 72 ms
71,764 KB
testcase_19 AC 71 ms
71,724 KB
testcase_20 AC 72 ms
71,844 KB
testcase_21 AC 72 ms
71,888 KB
testcase_22 AC 72 ms
71,800 KB
testcase_23 WA -
testcase_24 AC 73 ms
71,884 KB
testcase_25 AC 73 ms
71,728 KB
testcase_26 AC 74 ms
71,624 KB
testcase_27 AC 75 ms
71,768 KB
testcase_28 AC 72 ms
71,768 KB
testcase_29 AC 71 ms
71,344 KB
testcase_30 AC 71 ms
71,644 KB
testcase_31 AC 72 ms
71,840 KB
testcase_32 AC 75 ms
71,664 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 402 ms
153,824 KB
testcase_64 AC 400 ms
153,900 KB
testcase_65 AC 348 ms
135,504 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]
    st0 = []
    st1 = []

    while F and G:
        if F[-1][0] <= G[-1][0]:
            st0.append(F.pop())
        else:
            while st0 and st0[-1][1] <= G[-1][1]:
                st0.pop()
            st1.append(G.pop())
    while F:
        st0.append(F.pop())
    while G:
        while st0 and st0[-1][1] <= G[-1][1]:
            st0.pop()
        st1.append(G.pop())

    st0.reverse()
    st1.reverse()
    while st0 and st1:
        if st0[-1][0] <= st1[-1][0]:
            d[i].append(st0.pop())
        else:
            d[i].append(st1.pop())
    while st0:
        d[i].append(st0.pop())
    while st1:
        d[i].append(st1.pop())
    d[i].reverse()


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