結果
| 問題 | No.101 ぐるぐる!あみだくじ! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-02-11 18:58:44 |
| 言語 | Python3 (3.14.3 + numpy 2.4.2 + scipy 1.17.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 495 bytes |
| 記録 | |
| コンパイル時間 | 446 ms |
| コンパイル使用メモリ | 20,700 KB |
| 実行使用メモリ | 30,968 KB |
| 最終ジャッジ日時 | 2026-03-09 00:06:56 |
| 合計ジャッジ時間 | 88,185 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 TLE * 11 |
ソースコード
#!/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)