結果

問題 No.2740 Old Maid
ユーザー rlangevinrlangevin
提出日時 2024-04-20 10:28:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 468 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 82,368 KB
実行使用メモリ 143,840 KB
最終ジャッジ日時 2024-04-20 10:28:41
合計ジャッジ時間 10,516 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 175 ms
143,284 KB
testcase_01 WA -
testcase_02 AC 204 ms
143,216 KB
testcase_03 AC 179 ms
143,620 KB
testcase_04 WA -
testcase_05 AC 180 ms
143,340 KB
testcase_06 WA -
testcase_07 AC 182 ms
143,216 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 171 ms
143,840 KB
testcase_11 WA -
testcase_12 AC 159 ms
120,060 KB
testcase_13 AC 170 ms
124,988 KB
testcase_14 AC 98 ms
88,880 KB
testcase_15 AC 85 ms
94,464 KB
testcase_16 AC 135 ms
109,856 KB
testcase_17 AC 78 ms
87,404 KB
testcase_18 AC 163 ms
121,204 KB
testcase_19 AC 103 ms
101,504 KB
testcase_20 AC 189 ms
131,808 KB
testcase_21 AC 82 ms
91,392 KB
testcase_22 AC 137 ms
107,720 KB
testcase_23 AC 103 ms
83,712 KB
testcase_24 AC 104 ms
99,328 KB
testcase_25 AC 222 ms
134,404 KB
testcase_26 AC 52 ms
65,664 KB
testcase_27 AC 71 ms
79,872 KB
testcase_28 AC 141 ms
109,124 KB
testcase_29 AC 128 ms
104,704 KB
testcase_30 AC 56 ms
70,016 KB
testcase_31 AC 275 ms
142,212 KB
testcase_32 AC 113 ms
101,504 KB
testcase_33 AC 203 ms
135,924 KB
testcase_34 AC 137 ms
107,648 KB
testcase_35 AC 102 ms
99,584 KB
testcase_36 AC 104 ms
102,016 KB
testcase_37 AC 115 ms
98,688 KB
testcase_38 AC 94 ms
99,712 KB
testcase_39 AC 80 ms
86,144 KB
testcase_40 AC 178 ms
116,416 KB
testcase_41 AC 206 ms
132,108 KB
testcase_42 WA -
testcase_43 AC 34 ms
51,712 KB
testcase_44 AC 34 ms
52,224 KB
testcase_45 AC 33 ms
52,352 KB
testcase_46 AC 34 ms
51,968 KB
testcase_47 AC 33 ms
51,968 KB
testcase_48 AC 34 ms
52,224 KB
testcase_49 AC 35 ms
51,840 KB
testcase_50 AC 35 ms
52,352 KB
testcase_51 AC 35 ms
51,968 KB
testcase_52 WA -
testcase_53 AC 32 ms
52,608 KB
testcase_54 AC 34 ms
51,840 KB
testcase_55 AC 36 ms
51,840 KB
testcase_56 AC 40 ms
51,712 KB
testcase_57 AC 35 ms
52,224 KB
testcase_58 AC 37 ms
52,212 KB
testcase_59 AC 35 ms
51,968 KB
testcase_60 AC 45 ms
52,096 KB
testcase_61 WA -
testcase_62 AC 32 ms
51,840 KB
testcase_63 AC 33 ms
52,480 KB
testcase_64 AC 34 ms
51,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
P = list(map(int, input().split())) + ["$"]
nex = [-1] * (N + 1)
pre = [-1] * (N + 1)
for i in range(N):
    nex[P[i]] = P[i + 1]
    pre[P[i]] = P[i - 1]
    
ans = []
S = set()
for i in range(1, N):
    if nex[i] == "$" or i in S:
        continue
    ans.append(i)
    ans.append(nex[i])
    S.add(i)
    S.add(nex[i])
    p = pre[i]
    n = nex[nex[i]]
    if p != "$":
        nex[p] = n
    if n != "$":
        pre[n] = p
    
print(*ans)
    
0