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