結果
問題 | No.759 悪くない忘年会にしような! |
ユーザー | tktk_snsn |
提出日時 | 2022-05-12 13:08:56 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,721 bytes |
コンパイル時間 | 149 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 128,000 KB |
最終ジャッジ日時 | 2024-07-20 06:27:14 |
合計ジャッジ時間 | 16,734 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 49 ms
54,272 KB |
testcase_01 | AC | 48 ms
54,272 KB |
testcase_02 | AC | 49 ms
54,528 KB |
testcase_03 | AC | 52 ms
54,528 KB |
testcase_04 | AC | 48 ms
54,656 KB |
testcase_05 | AC | 51 ms
54,272 KB |
testcase_06 | AC | 46 ms
54,272 KB |
testcase_07 | AC | 44 ms
54,272 KB |
testcase_08 | AC | 43 ms
54,528 KB |
testcase_09 | AC | 43 ms
54,528 KB |
testcase_10 | AC | 43 ms
54,272 KB |
testcase_11 | AC | 43 ms
54,912 KB |
testcase_12 | AC | 42 ms
54,272 KB |
testcase_13 | AC | 42 ms
54,272 KB |
testcase_14 | AC | 42 ms
54,784 KB |
testcase_15 | AC | 43 ms
54,528 KB |
testcase_16 | AC | 43 ms
54,144 KB |
testcase_17 | AC | 41 ms
54,656 KB |
testcase_18 | AC | 41 ms
54,656 KB |
testcase_19 | AC | 42 ms
54,272 KB |
testcase_20 | AC | 42 ms
54,784 KB |
testcase_21 | AC | 41 ms
54,400 KB |
testcase_22 | AC | 41 ms
54,656 KB |
testcase_23 | AC | 41 ms
54,528 KB |
testcase_24 | AC | 43 ms
54,400 KB |
testcase_25 | AC | 44 ms
54,884 KB |
testcase_26 | AC | 44 ms
54,784 KB |
testcase_27 | AC | 44 ms
54,912 KB |
testcase_28 | AC | 44 ms
54,272 KB |
testcase_29 | WA | - |
testcase_30 | AC | 44 ms
54,912 KB |
testcase_31 | AC | 43 ms
54,528 KB |
testcase_32 | AC | 43 ms
54,656 KB |
testcase_33 | AC | 257 ms
81,280 KB |
testcase_34 | AC | 108 ms
77,696 KB |
testcase_35 | AC | 204 ms
80,584 KB |
testcase_36 | AC | 218 ms
81,536 KB |
testcase_37 | AC | 125 ms
78,592 KB |
testcase_38 | AC | 234 ms
81,792 KB |
testcase_39 | AC | 130 ms
78,592 KB |
testcase_40 | AC | 223 ms
82,048 KB |
testcase_41 | AC | 238 ms
82,176 KB |
testcase_42 | AC | 248 ms
81,852 KB |
testcase_43 | AC | 250 ms
82,700 KB |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | AC | 275 ms
83,072 KB |
testcase_50 | AC | 279 ms
82,304 KB |
testcase_51 | AC | 253 ms
82,048 KB |
testcase_52 | AC | 248 ms
82,560 KB |
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 | 640 ms
127,336 KB |
testcase_64 | WA | - |
testcase_65 | AC | 601 ms
115,120 KB |
testcase_66 | WA | - |
ソースコード
from collections import deque import heapq 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 in enumerate(P): d[ptoi[p]].append(i) for i in range(M): stack = [] d[i].sort(key=lambda j: (Q[j], R[j])) for j in d[i]: if stack and R[stack[-1]] < R[j]: stack.pop() stack.append(j) d[i] = stack d[i].reverse() def merge(i, j): F = d[i] G = d[j] stf = [] stg = [] while F and G: if Q[F[-1]] <= Q[G[-1]]: heapq.heappush(stf, (R[F[-1]], F[-1])) F.pop() else: while stf and stf[0][0] <= R[G[-1]]: heapq.heappop(stf) stg.append(G.pop()) while F: heapq.heappush(stf, (R[F[-1]], F[-1])) F.pop() while G: while stf and stf[0][0] <= R[G[-1]]: heapq.heappop(stf) stg.append(G.pop()) stf = [k for _, k in stf] stf.sort(key=lambda k: Q[k], reverse=True) stg.reverse() while stf and stg: if Q[stf[-1]] <= Q[stg[-1]]: d[i].append(stf.pop()) else: d[i].append(stg.pop()) while stf: d[i].append(stf.pop()) while stg: d[i].append(stg.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 = [i + 1 for i in d[0]] ans.sort() print(*ans, sep="\n")