結果
| 問題 | No.482 あなたの名は |
| コンテスト | |
| ユーザー |
fiord
|
| 提出日時 | 2017-02-27 21:10:42 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 2,000 ms |
| + 472µs | |
| コード長 | 516 bytes |
| 記録 | |
| コンパイル時間 | 431 ms |
| コンパイル使用メモリ | 85,852 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-25 17:17:33 |
| 合計ジャッジ時間 | 3,046 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main() {
ll n, k; cin >> n >> k;
vector<int> a(n), pos(n);
for (int i = 0; i < n; i++) {
cin >> a[i]; a[i]--;
pos[a[i]] = i;
}
ll need = 0;
for (int i = 0; i < n; i++) {
if (a[i] != i) {
need++;
swap(a[i], a[pos[i]]);
swap(pos[a[i]], pos[a[pos[i]]]);
}
}
if (need > k) cout << "NO" << endl;
else if ((k - need) % 2 == 0) cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
}
fiord