結果
| 問題 |
No.2428 Returning Shuffle
|
| ユーザー |
|
| 提出日時 | 2023-08-18 22:36:16 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 750 bytes |
| コンパイル時間 | 5,634 ms |
| コンパイル使用メモリ | 218,368 KB |
| 実行使用メモリ | 54,732 KB |
| 最終ジャッジ日時 | 2024-11-28 08:38:24 |
| 合計ジャッジ時間 | 21,226 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 TLE * 4 |
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(3130): Warning: cannot inline function `std.numeric.gcdImpl!(BigInt).gcdImpl`
ソースコード
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);
}