結果
問題 | No.326 あみだますたー |
ユーザー |
![]() |
提出日時 | 2019-08-28 20:39:34 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 804 bytes |
コンパイル時間 | 348 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 78,208 KB |
最終ジャッジ日時 | 2024-11-17 16:33:07 |
合計ジャッジ時間 | 3,392 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
51,840 KB |
testcase_01 | AC | 30 ms
52,224 KB |
testcase_02 | MLE | - |
testcase_03 | MLE | - |
testcase_04 | MLE | - |
testcase_05 | AC | 34 ms
57,984 KB |
testcase_06 | MLE | - |
testcase_07 | MLE | - |
testcase_08 | MLE | - |
testcase_09 | MLE | - |
testcase_10 | MLE | - |
testcase_11 | AC | 32 ms
52,352 KB |
testcase_12 | MLE | - |
testcase_13 | MLE | - |
testcase_14 | MLE | - |
testcase_15 | MLE | - |
testcase_16 | MLE | - |
testcase_17 | MLE | - |
testcase_18 | MLE | - |
testcase_19 | MLE | - |
testcase_20 | AC | 31 ms
52,352 KB |
testcase_21 | AC | 32 ms
51,584 KB |
testcase_22 | MLE | - |
testcase_23 | MLE | - |
testcase_24 | MLE | - |
testcase_25 | MLE | - |
testcase_26 | MLE | - |
testcase_27 | MLE | - |
ソースコード
N = int(input()) K = int(input()) XY = [tuple(map(int, input().split())) for _ in range(K)] XY = list(map(lambda k: (k[0]-1, k[1]-1), XY)) A = list(map(int, input().split())) A = list(map(lambda k: k-1, A)) mid_state = [0] * N for i in range(N): pos = i for j in range(K): if pos == XY[j][0]: pos = XY[j][1] elif pos == XY[j][1]: pos = XY[j][0] mid_state[pos] = i last_state = [0] * N for i in range(N): last_state[A[i]] = i ans = [] for i in range(N): for j in range(N): if mid_state[j] == last_state[i]: for k in range(j, i, -1): ans.append((k-1, k)) mid_state.insert(0, mid_state.pop(j)) break print(len(ans)) for Xi, Yi in ans: print(Xi+1, Yi+1)