結果
| 問題 |
No.101 ぐるぐる!あみだくじ!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-02-11 18:58:44 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 495 bytes |
| コンパイル時間 | 83 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 17,692 KB |
| 最終ジャッジ日時 | 2024-06-23 18:52:32 |
| 合計ジャッジ時間 | 24,684 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 24 TLE * 1 -- * 12 |
ソースコード
#!/usr/bin/env python3
from functools import reduce
def swap(l, i):
l[i[0] - 1], l[i[1] - 1] = l[i[1] - 1], l[i[0] - 1]
return l
def shufle(bars, l):
return [bars[x] for x in l]
N = int(input())
K = int(input())
initial = list(range(N))
bar = [()] * K
for i in range(K):
bar[i] = tuple(map(int, input().split()))
bars = list(reduce(swap, bar, list(initial)))
l = shufle(bars, list(initial))
count = 1
while l != initial:
l = shufle(bars, l)
count += 1
print(count)