結果
| 問題 |
No.482 あなたの名は
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-21 11:17:01 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 664 bytes |
| コンパイル時間 | 627 ms |
| コンパイル使用メモリ | 67,188 KB |
| 実行使用メモリ | 7,840 KB |
| 最終ジャッジ日時 | 2025-09-21 11:17:04 |
| 合計ジャッジ時間 | 2,574 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%d%d", &n, &k);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d", &a[i]);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include <iostream>
using namespace std;
typedef long long LL;
const int N = 200010;
int n, k, a[N], b[N];
LL cnt;
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;
}