結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2025-09-20 17:56:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 735 bytes |
コンパイル時間 | 1,709 ms |
コンパイル使用メモリ | 193,188 KB |
実行使用メモリ | 10,824 KB |
最終ジャッジ日時 | 2025-09-20 17:56:49 |
合計ジャッジ時間 | 4,351 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 WA * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll const int N = 5e5 + 7; int n, m, a[N], p[N]; signed main() { // freopen("soul.in", "r", stdin); // freopen("soul.out", "w", stdout); ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i], p[a[i]] = i; int sum = 0; for (int i = 1; i <= n; i++) { if (p[i] == i) continue; else { sum++; p[a[i]] = p[i]; p[i] = i; swap(a[i], a[p[i]]); } } if (m < sum) puts("NO"); else if ((m - sum) & 1) puts("NO"); else puts("YES"); }