結果

問題 No.2740 Old Maid
ユーザー mkawa2mkawa2
提出日時 2024-04-20 14:17:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 309 ms / 2,000 ms
コード長 1,102 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 82,284 KB
実行使用メモリ 133,732 KB
最終ジャッジ日時 2024-04-20 14:17:20
合計ジャッジ時間 11,361 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 178 ms
131,632 KB
testcase_01 AC 204 ms
131,668 KB
testcase_02 AC 177 ms
131,688 KB
testcase_03 AC 177 ms
131,664 KB
testcase_04 AC 179 ms
131,952 KB
testcase_05 AC 180 ms
131,676 KB
testcase_06 AC 203 ms
131,640 KB
testcase_07 AC 178 ms
131,868 KB
testcase_08 AC 189 ms
131,756 KB
testcase_09 AC 177 ms
131,676 KB
testcase_10 AC 174 ms
131,672 KB
testcase_11 AC 184 ms
131,732 KB
testcase_12 AC 175 ms
121,768 KB
testcase_13 AC 189 ms
128,080 KB
testcase_14 AC 82 ms
87,456 KB
testcase_15 AC 93 ms
92,628 KB
testcase_16 AC 144 ms
120,156 KB
testcase_17 AC 87 ms
85,828 KB
testcase_18 AC 182 ms
122,360 KB
testcase_19 AC 119 ms
100,912 KB
testcase_20 AC 212 ms
133,552 KB
testcase_21 AC 89 ms
89,352 KB
testcase_22 AC 142 ms
120,128 KB
testcase_23 AC 77 ms
82,796 KB
testcase_24 AC 108 ms
100,828 KB
testcase_25 AC 216 ms
126,796 KB
testcase_26 AC 65 ms
67,844 KB
testcase_27 AC 68 ms
76,416 KB
testcase_28 AC 145 ms
120,644 KB
testcase_29 AC 135 ms
115,760 KB
testcase_30 AC 61 ms
70,528 KB
testcase_31 AC 309 ms
129,296 KB
testcase_32 AC 112 ms
104,576 KB
testcase_33 AC 251 ms
122,300 KB
testcase_34 AC 139 ms
115,940 KB
testcase_35 AC 104 ms
97,992 KB
testcase_36 AC 107 ms
100,968 KB
testcase_37 AC 125 ms
112,156 KB
testcase_38 AC 100 ms
97,372 KB
testcase_39 AC 79 ms
85,116 KB
testcase_40 AC 158 ms
116,812 KB
testcase_41 AC 233 ms
133,732 KB
testcase_42 AC 40 ms
52,532 KB
testcase_43 AC 41 ms
52,520 KB
testcase_44 AC 40 ms
52,736 KB
testcase_45 AC 40 ms
53,428 KB
testcase_46 AC 40 ms
52,648 KB
testcase_47 AC 40 ms
53,700 KB
testcase_48 AC 40 ms
53,212 KB
testcase_49 AC 39 ms
52,464 KB
testcase_50 AC 39 ms
53,512 KB
testcase_51 AC 39 ms
53,268 KB
testcase_52 AC 39 ms
52,460 KB
testcase_53 AC 40 ms
52,856 KB
testcase_54 AC 40 ms
53,408 KB
testcase_55 AC 40 ms
53,252 KB
testcase_56 AC 39 ms
53,260 KB
testcase_57 AC 40 ms
52,892 KB
testcase_58 AC 40 ms
53,880 KB
testcase_59 AC 40 ms
52,672 KB
testcase_60 AC 40 ms
53,016 KB
testcase_61 AC 46 ms
53,192 KB
testcase_62 AC 40 ms
53,468 KB
testcase_63 AC 39 ms
52,528 KB
testcase_64 AC 39 ms
53,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
# sys.set_int_max_str_digits(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = -1-(-1 << 31)
inf = -1-(-1 << 62)

# md = 10**9+7
md = 998244353

n=II()
pp=LI1()

ll=list(range(-1,n+3))
rr=list(range(1,n+3))
p2i={p:i for i,p in enumerate(pp)}

ans=[]
fin=[0]*n
for p in range(n):
    if fin[p]:continue
    i=p2i[p]
    j=rr[i]
    if j>=n:continue
    q=pp[j]
    ans.append(p+1)
    ans.append(q+1)
    fin[p]=fin[q]=1
    a=ll[i]
    b=rr[j]
    rr[a]=b
    ll[b]=a
print(*ans)
0