結果

問題 No.2428 Returning Shuffle
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2023-08-18 21:35:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 748 bytes
コンパイル時間 828 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 271,312 KB
最終ジャッジ日時 2024-05-06 03:29:38
合計ジャッジ時間 5,652 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 38 ms
52,096 KB
testcase_04 AC 41 ms
51,968 KB
testcase_05 AC 39 ms
52,352 KB
testcase_06 AC 38 ms
52,096 KB
testcase_07 AC 41 ms
52,352 KB
testcase_08 AC 40 ms
51,840 KB
testcase_09 AC 40 ms
52,224 KB
testcase_10 AC 36 ms
52,096 KB
testcase_11 AC 40 ms
52,096 KB
testcase_12 AC 40 ms
51,968 KB
testcase_13 AC 41 ms
51,840 KB
testcase_14 AC 41 ms
52,096 KB
testcase_15 AC 41 ms
52,096 KB
testcase_16 AC 39 ms
52,224 KB
testcase_17 AC 40 ms
51,840 KB
testcase_18 AC 40 ms
51,840 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 37 ms
52,096 KB
testcase_22 AC 36 ms
52,096 KB
testcase_23 AC 38 ms
51,840 KB
testcase_24 AC 381 ms
271,308 KB
testcase_25 AC 369 ms
271,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""


"""

import sys
from sys import stdin

N,M = map(int,stdin.readline().split())

p = [i for i in range(N)]

for lp in range(M):

    ts = list(map(int,stdin.readline().split()))

    s = []

    for j in range(1,len(ts)):
        s.append(ts[j]-1)
    s.reverse()

    pz = p[s[0]]

    for i in range(len(s)-1):
        p[s[i]] = p[s[i+1]]
    p[s[-1]] = pz

    #print (p)


end = [False] * N

c = []

for i in range(N):

    if not end[i]:

        v = i
        now = 0
        
        while True:
            end[v] = True
            v = p[v]
            now += 1
            if v == i:
                break

        c.append(now)

#print (c,p)

ans = 1
import math

for i in c:
    
    ans = i * ans // math.gcd(i,ans)

print (ans)
0