結果
問題 | No.2740 Old Maid |
ユーザー | norioc |
提出日時 | 2024-04-24 01:37:55 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 266 ms / 2,000 ms |
コード長 | 1,386 bytes |
コンパイル時間 | 242 ms |
コンパイル使用メモリ | 82,440 KB |
実行使用メモリ | 177,736 KB |
最終ジャッジ日時 | 2024-11-06 08:16:47 |
合計ジャッジ時間 | 12,149 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 216 ms
177,584 KB |
testcase_01 | AC | 218 ms
177,536 KB |
testcase_02 | AC | 218 ms
177,324 KB |
testcase_03 | AC | 220 ms
174,068 KB |
testcase_04 | AC | 225 ms
173,972 KB |
testcase_05 | AC | 221 ms
173,752 KB |
testcase_06 | AC | 221 ms
177,544 KB |
testcase_07 | AC | 222 ms
173,692 KB |
testcase_08 | AC | 221 ms
177,696 KB |
testcase_09 | AC | 224 ms
177,216 KB |
testcase_10 | AC | 218 ms
177,736 KB |
testcase_11 | AC | 215 ms
176,784 KB |
testcase_12 | AC | 207 ms
138,424 KB |
testcase_13 | AC | 218 ms
147,016 KB |
testcase_14 | AC | 94 ms
92,176 KB |
testcase_15 | AC | 102 ms
98,744 KB |
testcase_16 | AC | 175 ms
119,948 KB |
testcase_17 | AC | 91 ms
90,180 KB |
testcase_18 | AC | 213 ms
139,056 KB |
testcase_19 | AC | 117 ms
97,728 KB |
testcase_20 | AC | 236 ms
158,904 KB |
testcase_21 | AC | 96 ms
95,028 KB |
testcase_22 | AC | 178 ms
119,500 KB |
testcase_23 | AC | 85 ms
86,380 KB |
testcase_24 | AC | 120 ms
97,336 KB |
testcase_25 | AC | 251 ms
165,224 KB |
testcase_26 | AC | 59 ms
68,064 KB |
testcase_27 | AC | 77 ms
81,668 KB |
testcase_28 | AC | 176 ms
119,768 KB |
testcase_29 | AC | 167 ms
114,524 KB |
testcase_30 | AC | 64 ms
72,368 KB |
testcase_31 | AC | 266 ms
176,852 KB |
testcase_32 | AC | 126 ms
100,380 KB |
testcase_33 | AC | 248 ms
167,172 KB |
testcase_34 | AC | 171 ms
114,408 KB |
testcase_35 | AC | 113 ms
95,624 KB |
testcase_36 | AC | 116 ms
97,628 KB |
testcase_37 | AC | 153 ms
107,636 KB |
testcase_38 | AC | 105 ms
95,040 KB |
testcase_39 | AC | 87 ms
89,608 KB |
testcase_40 | AC | 195 ms
129,484 KB |
testcase_41 | AC | 233 ms
158,020 KB |
testcase_42 | AC | 38 ms
52,816 KB |
testcase_43 | AC | 38 ms
52,816 KB |
testcase_44 | AC | 39 ms
52,592 KB |
testcase_45 | AC | 39 ms
52,460 KB |
testcase_46 | AC | 38 ms
52,532 KB |
testcase_47 | AC | 38 ms
53,088 KB |
testcase_48 | AC | 39 ms
54,024 KB |
testcase_49 | AC | 38 ms
52,656 KB |
testcase_50 | AC | 39 ms
54,076 KB |
testcase_51 | AC | 38 ms
53,888 KB |
testcase_52 | AC | 39 ms
52,636 KB |
testcase_53 | AC | 37 ms
52,880 KB |
testcase_54 | AC | 38 ms
52,940 KB |
testcase_55 | AC | 38 ms
53,156 KB |
testcase_56 | AC | 39 ms
53,532 KB |
testcase_57 | AC | 39 ms
53,416 KB |
testcase_58 | AC | 38 ms
52,640 KB |
testcase_59 | AC | 39 ms
53,564 KB |
testcase_60 | AC | 38 ms
52,748 KB |
testcase_61 | AC | 38 ms
54,088 KB |
testcase_62 | AC | 38 ms
53,076 KB |
testcase_63 | AC | 38 ms
52,808 KB |
testcase_64 | AC | 39 ms
52,820 KB |
ソースコード
class Node: def __init__(self, x): self.x = x self.prev = None self.next = None class LinkedList: def __init__(self): self.front = Node(None) self.back = self.front pass def append(self, x): node = Node(x) node.prev = self.back self.back.next = node self.back = node return node def appendleft(self, x): front = self.front node = Node(x) next = front.next if next is None: node.prev = front front.next = node else: next.prev = node node.next = next node.prev = front front.next = node self.front = node return node def remove(self, node: Node): prev = node.prev next = node.next assert prev is not None prev.next = next if next is not None: next.prev = prev N = int(input()) P = list(map(lambda x: int(x)-1, input().split())) ll = LinkedList() d = {} for p in P: node = ll.append(p) d[p] = node used = set() ans = [] for i in range(N): if i in used: continue node = d[i] next = node.next if next is None: continue ans.append(node.x + 1) ans.append(next.x + 1) used.add(node.x) used.add(next.x) ll.remove(node) ll.remove(next) print(*ans)