結果
問題 |
No.2289 順列ソート
|
ユーザー |
![]() |
提出日時 | 2025-10-04 15:48:31 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 331 bytes |
コンパイル時間 | 3,411 ms |
コンパイル使用メモリ | 275,336 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-10-04 15:48:37 |
合計ジャッジ時間 | 4,735 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int p[n+1]; for(int i=1;i<=n;i++){ cin>>p[i]; } int time=0; for(int i=1;i<=n;i++){ if(p[i]!=i){ for(int j=1;j<=n;j++){ if(p[j]==i){ swap(p[i],p[j]); time++; } } } else{ continue; } } cout<<time<<endl; return 0; }