結果

問題 No.2428 Returning Shuffle
ユーザー laneguelanegue
提出日時 2023-08-18 22:36:16
言語 D
(dmd 2.106.1)
結果
TLE  
実行時間 -
コード長 750 bytes
コンパイル時間 3,481 ms
コンパイル使用メモリ 211,800 KB
実行使用メモリ 23,808 KB
最終ジャッジ日時 2023-08-18 22:36:28
合計ジャッジ時間 10,109 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import std;
const ulong MOD = 998244353;
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;
    }
  }
  auto result = BigInt(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(BigInt(k));
  }
  writeln(result % MOD);
}
0