結果

問題 No.2428 Returning Shuffle
ユーザー laneguelanegue
提出日時 2023-08-18 22:11:00
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 712 bytes
コンパイル時間 4,948 ms
コンパイル使用メモリ 161,404 KB
実行使用メモリ 44,316 KB
最終ジャッジ日時 2023-08-18 22:11:24
合計ジャッジ時間 5,013 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 180 ms
43,920 KB
testcase_25 AC 185 ms
44,316 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/dmd2/linux/bin64/../../src/phobos/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!ulong.gcdImpl`

ソースコード

diff #

import std;
void main(){
  auto input = readln.chomp.split.to!(int[]);
  int n = input[0];
  int m = input[1];
  auto s = new int[n];
  for(auto i = 0; i < n; i++){
    s[i] = i;
  }
  for(auto i = 0; i < m; i++){
    input = readln.chomp.split.to!(int[]);
    int prev = s[input[$ - 1] - 1];
    for(auto j = 1; j < input.length; j++){
      auto t = s[input[j] - 1];
      s[input[j] - 1] = prev;
      prev = t;
    }
  }
  ulong result = 1;
  auto closed = new bool[n];
  for(auto i = 0; i < n; i++){
    if(closed[i]) continue;
    auto j = i;
    ulong k = 0L;
    while(!closed[j]){
      closed[j] = true;
      j = s[j];
      k++;
    }
    result = result.lcm(k);
  }
  writeln(result % 998244353);
}
0