結果
| 問題 |
No.482 あなたの名は
|
| ユーザー |
|
| 提出日時 | 2017-02-10 22:28:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 456 bytes |
| コンパイル時間 | 791 ms |
| コンパイル使用メモリ | 69,348 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-28 06:34:37 |
| 合計ジャッジ時間 | 3,096 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 7 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
long long K;
cin >> n >> K;
vector<int> D(n);
vector<int> pos(n);
for (int i = 0; i < n; i++) {
cin >> D[i];
D[i]--;
pos[D[i]] = i;
}
int ans = 0;
for (int i = 0; i < n; i++) {
if (D[i] != i) {
int j = pos[i];
swap(D[i], D[j]);
pos[D[i]] = j;
pos[D[j]] = i;
ans++;
}
}
cout << (ans <= K && (K - ans) % 2 == 0 ? "YES" : "NO") << endl;
}