結果
| 問題 |
No.101 ぐるぐる!あみだくじ!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-02-02 15:36:18 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 472 bytes |
| コンパイル時間 | 201 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-06-11 09:27:19 |
| 合計ジャッジ時間 | 2,566 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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()