結果
問題 | No.482 あなたの名は |
ユーザー |
![]() |
提出日時 | 2017-02-10 22:52:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 528 bytes |
コンパイル時間 | 624 ms |
コンパイル使用メモリ | 70,576 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-28 08:48:39 |
合計ジャッジ時間 | 2,924 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 WA * 10 |
ソースコード
#include <iostream>#include <vector>using namespace std;using ll = long long;int main(){ll N, K;cin >> N >> K;vector<ll> D(N), p(N);for (ll i = 0; i < N; i++) {cin >> D[i];D[i] -= 1LL;p[D[i]] = i;}for (ll i = 0; i < N; i++) {if (p[i] == i) continue;swap(p[i], p[D[i]]);K -= 1LL;}if (K < 0LL) {cout << "NO" << endl;} else {cout << (K % 2LL == 0LL ? "YES" : "NO") << endl;}return 0;}