結果
問題 | No.326 あみだますたー |
ユーザー |
![]() |
提出日時 | 2020-02-24 21:22:05 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 828 bytes |
コンパイル時間 | 292 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 11,264 KB |
最終ジャッジ日時 | 2024-10-12 12:57:25 |
合計ジャッジ時間 | 2,795 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 26 |
ソースコード
#!/usr/bin/env python3# %%import sysread = sys.stdin.buffer.readreadline = sys.stdin.buffer.readlinereadlines = sys.stdin.buffer.readlines# %%N = int(readline())K = int(readline())X = [0] * KY = [0] * Kfor i in range(K):X[i], Y[i] = map(int, readline().split())*A, = map(int, read().split())# %%before = list(range(N))for x, y in zip(X, Y):x -= 1y -= 1before[x], before[y] = before[y], before[x]after = [0] * Nfor i, x in enumerate(A):after[x - 1] = i# %%convert = {x: i for i, x in enumerate(after)}B = [convert[x] for x in before]# %%operations = []for n in range(1, N):while n > 0 and B[n] < B[n - 1]:operations.append(n)B[n], B[n - 1] = B[n - 1], B[n]n -= 1# %%print(len(operations))print('\n'.join(f'{x} {x+1}' for x in operations))