結果
問題 |
No.482 あなたの名は
|
ユーザー |
|
提出日時 | 2017-06-29 22:55:23 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 663 bytes |
コンパイル時間 | 632 ms |
コンパイル使用メモリ | 73,932 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-04 16:53:59 |
合計ジャッジ時間 | 3,430 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 28 |
ソースコード
#include<cstdio> #include <iostream> #include<algorithm> #include<string> #include<queue> #include<vector> #include<functional> #include<cmath> #include<map> #include<stack> #include<set> #include<numeric> #define mod 1000000007; using namespace std; typedef long long ll; typedef pair<ll, ll> Pr; ll N, K; ll D[200010],ind[200010]; int main() { cin >> N >> K; for (ll i = 1; i <= N; i++) { cin >> D[i]; ind[i] = D[i]; } ll cnt = 0; for (ll i = 1; i <= N; i++) { if (D[i] != i) { swap(D[ind[i]],D[i]); cnt++; } } cout << cnt << endl; if (K < cnt || (K - cnt) % 2 != 0) cout << "NO" << endl; else cout << "YES" << endl; return 0; }