結果
| 問題 |
No.326 あみだますたー
|
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2019-12-26 15:47:11 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 475 ms / 2,000 ms |
| コード長 | 1,321 bytes |
| コンパイル時間 | 135 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 44,300 KB |
| 最終ジャッジ日時 | 2024-10-04 08:40:20 |
| 合計ジャッジ時間 | 14,542 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 26 |
ソースコード
from itertools import *
from bisect import *
from math import *
from collections import *
from heapq import *
from random import *
import numpy as np
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def main():
def make_bar(now,goal):
for i in range(now,goal,-1):
ans.append([i,i+1])
line[i-1],line[i]=line[i],line[i-1]
n=II()
k=II()
line=list(range(n))
for _ in range(k):
x,y=MI1()
line[x],line[y]=line[y],line[x]
#print(line)
ans=[]
aa=LI1()
hp=[]
for start,goal in enumerate(aa):
heappush(hp,[goal,start])
while hp:
goal,start=heappop(hp)
now=line.index(start)
make_bar(now,goal)
#print(line)
print(len(ans))
for x in ans:
print(*x)
main()
mkawa2