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