結果

問題 No.3726 Flawless Flow
コンテスト
ユーザー sig
提出日時 2026-10-15 04:23:21
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 58 ms / 2,000 ms
+ 559µs
コード長 430 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 83 ms
コンパイル使用メモリ 64,512 KB
実行使用メモリ 63,208 KB
最終ジャッジ日時 2026-10-15 04:23:27
合計ジャッジ時間 6,089 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 59
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ind = [0]*(n+1)
for i in range(n):
	ind[b[i]] = i
ans = []
ans.append(a[:])
for i in range(n):
	can = True
	if i%2:
		for j in range(1,n-1,2):
			if ind[a[j]] > ind[a[j+1]]:
				a[j],a[j+1] = a[j+1],a[j]
	else:
		for j in range(0,n-1,2):
			if ind[a[j]] > ind[a[j+1]]:
				a[j],a[j+1] = a[j+1],a[j]
	ans.append(a[:])
for i in ans:
	print(*i)
0