結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2025-09-20 17:58:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 748 bytes |
コンパイル時間 | 1,741 ms |
コンパイル使用メモリ | 193,208 KB |
実行使用メモリ | 10,388 KB |
最終ジャッジ日時 | 2025-09-20 17:58:47 |
合計ジャッジ時間 | 3,776 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#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]; swap(a[i], a[p[i]]); p[i] = i; } } if (m < sum) puts("NO"); else if ((m - sum) & 1) puts("NO"); else puts("YES"); }