結果

問題 No.101 ぐるぐる!あみだくじ!
ユーザー warashi
提出日時 2015-02-11 18:51:15
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 448 bytes
コンパイル時間 120 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 17,820 KB
最終ジャッジ日時 2024-06-23 18:46:31
合計ジャッジ時間 7,454 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 11 TLE * 1 -- * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/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(bar, l):
    return list(reduce(swap, bar, 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()))

l = shufle(bar, list(initial))
count = 1
while l != initial:
    shufle(bar, l)
    count += 1
print(count)
0