結果

問題 No.101 ぐるぐる!あみだくじ!
コンテスト
ユーザー warashi
提出日時 2015-02-11 18:58:44
言語 Python3
(3.14.3 + numpy 2.4.2 + scipy 1.17.0)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 495 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 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
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#!/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)
0