結果

問題 No.101 ぐるぐる!あみだくじ!
ユーザー バカらっく
提出日時 2019-09-30 01:48:31
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 674 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 16,000 KB
最終ジャッジ日時 2024-10-03 04:48:04
合計ジャッジ時間 7,005 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 11 TLE * 1 -- * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding:utf-8 -*-

columnCuount = int(input())
barCount = int(input())

barMap = []

for i in range(barCount):
    barMap.append([int(j) - 1 for j in input().rstrip().split(" ")])

numList = [[i, i] for i in range(columnCuount)]


def getGoal(column):
    current = column
    for (f, t) in barMap:
        if t == current:
            current = f
        elif f == current:
            current = t
    return current


moveList = [getGoal(i) for i in range(columnCuount)]

for i in range(1000000):
    tmp = sorted([[moveList[i], v] for (i, v) in numList])
    if len([[i,v] for (i,v) in tmp if i != v]) == 0:
        print(str(i+1))
        exit(0)
    numList = tmp
0