結果
問題 | No.2289 順列ソート |
ユーザー |
|
提出日時 | 2024-04-09 08:46:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 410 bytes |
コンパイル時間 | 4,301 ms |
コンパイル使用メモリ | 253,240 KB |
最終ジャッジ日時 | 2025-02-20 23:17:37 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using mint = modint998244353; void solve() { int N; cin >> N; dsu uf(N); for (int i = 0; i < N; i++) { int p; cin >> p; p--; uf.merge(i, p); } cout << N - uf.groups().size() << endl; } int main() { int T; T = 1; while (T--) solve(); return 0; }