結果
問題 |
No.482 あなたの名は
|
ユーザー |
|
提出日時 | 2025-09-21 11:20:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 666 bytes |
コンパイル時間 | 634 ms |
コンパイル使用メモリ | 67,192 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-21 11:20:49 |
合計ジャッジ時間 | 2,739 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 WA * 4 |
コンパイルメッセージ
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%lld", &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, a[N], b[N]; LL k, cnt; int main() { // freopen("soul.in", "r", stdin); // freopen("soul.out", "w", stdout); scanf("%d%lld", &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; }