結果
問題 | No.101 ぐるぐる!あみだくじ! |
ユーザー |
![]() |
提出日時 | 2021-10-26 15:08:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 497 bytes |
コンパイル時間 | 4,729 ms |
コンパイル使用メモリ | 250,672 KB |
最終ジャッジ日時 | 2025-01-25 07:14:51 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 100000000000 int main(){ int N; cin>>N; vector<int> a(N); rep(i,N)a[i] = i; int K; cin>>K; rep(i,K){ int x,y; cin>>x>>y; swap(a[x],a[x-1]); } dsu D(N); rep(i,N){ D.merge(i,a[i]); } long long ans = 1LL; rep(i,N){ ans = lcm(ans,(long long)D.size(i)); } cout<<ans<<endl; return 0; }