結果
| 問題 |
No.2289 順列ソート
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-05 21:21:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 310 bytes |
| コンパイル時間 | 658 ms |
| コンパイル使用メモリ | 63,232 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-23 05:45:12 |
| 合計ジャッジ時間 | 1,261 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include<iostream>
using namespace std;
int N;
int P[101];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N;
for(int i=1;i<=N;i++)cin>>P[i];
int cnt=0;
for(int i=1;i<=N;i++)if(P[i])
{
int u=i;
while(P[u])
{
int v=P[u];
P[u]=0;
u=v;
}
cnt++;
}
cout<<N-cnt<<endl;
}