結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-21 11:16:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 638 bytes |
| コンパイル時間 | 614 ms |
| コンパイル使用メモリ | 66,976 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-09-21 11:16:21 |
| 合計ジャッジ時間 | 3,190 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d%d", &n, &k);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%d", &a[i]);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include <iostream>
using namespace std;
const int N = 200010;
int n, k, a[N], cnt, b[N];
int main() {
// freopen("soul.in", "r", stdin);
// freopen("soul.out", "w", stdout);
scanf("%d%d", &n, &k);
for (int i = 1; i <= n; ++i) {
scanf("%d", &a[i]);
b[a[i]] = i;
}
for (int i = 1; i <= n; ++i) {
if (i != b[i]) {
swap(a[i], a[b[a[i]]]);
int temp1 = b[i], temp2 = b[a[i]];
b[a[i]] = temp1;
b[i] = temp2;
++cnt;
}
}
if (cnt <= k && (k - cnt) % 2 == 0) puts("YES");
else puts("NO");
return 0;
}