結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-11-15 23:32:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 746 bytes |
| コンパイル時間 | 652 ms |
| コンパイル使用メモリ | 61,640 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-24 14:06:38 |
| 合計ジャッジ時間 | 3,540 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 WA * 11 |
ソースコード
#include<iostream>
#include<vector>
using namespace std;
int main() {
int n = 0;
long k = 0;
vector<int> d;
cin >> n>>k;
long buff = k;
d.resize(n,0);
for (int i = 0;i < n;i++) {
cin >> d[i];
}
int j = 0;
while (j!=n-1) {
if (d[j] != j+1) {
int tmp = 0;
tmp = d[j];
d[j] = d[tmp - 1];
d[tmp - 1] = tmp;
k--;
}
else {
j++;
}
if (k < 0)break;
}
if (k == 0)cout << "YES" << endl;
else if (k < 0)cout << "NO" << endl;
else if (k > 0) {
long x = buff - k;
if (x == 0) {
if (buff % 2 == 0) {
cout << "YES" << endl;
}
else {
cout << "NO" << endl;
}
}
else {
if (buff % 2 != 0) {
cout << "YES" << endl;
}
else {
cout << "NO" << endl;
}
}
}
return 0;
}