結果
問題 | No.482 あなたの名は |
ユーザー |
|
提出日時 | 2017-04-20 03:54:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 566 bytes |
コンパイル時間 | 313 ms |
コンパイル使用メモリ | 48,256 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 10:42:40 |
合計ジャッジ時間 | 1,886 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 WA * 3 |
ソースコード
#include <cstdio>#include <vector>#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))using namespace std;int main() {int n, k; scanf("%d%d", &n, &k);vector<int> d(n); repeat (i,n) { scanf("%d", &d[i]); -- d[i]; }vector<int> e(n); repeat (i,n) e[d[i]] = i;repeat (i,n) {if (d[i] != i) {int j = e[i];swap(d[i], d[j]);e[d[i]] = i;e[d[j]] = j;k -= 1;}}bool result = k >= 0 and k % 2 == 0;printf("%s\n", result ? "YES" : "NO");return 0;}