結果
| 問題 |
No.101 ぐるぐる!あみだくじ!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-02-02 15:36:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 472 bytes |
| コンパイル時間 | 231 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 59,776 KB |
| 最終ジャッジ日時 | 2024-06-11 09:26:47 |
| 合計ジャッジ時間 | 2,862 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 37 |
ソースコード
import sys
import math
def input(): return sys.stdin.readline().rstrip()
def main():
N = int(input())
K = int(input())
*A, = range(N)
for i in range(K):
X, Y = map(int, input().split())
A[X-1], A[Y-1] = A[Y-1], A[X-1]
ans = 0
for i in range(N):
c = 1
j = A[i]
while j != i:
c += 1
j = A[j]
ans = math.lcm(ans, c)
print(ans)
if __name__ == '__main__':
main()