結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2019-01-16 21:12:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 502 bytes |
コンパイル時間 | 785 ms |
コンパイル使用メモリ | 69,120 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 16:53:27 |
合計ジャッジ時間 | 2,837 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 15 WA * 13 |
ソースコード
#include <iostream> #include <vector> using namespace std; int main() { int N, K; cin >> N >> K; vector<int> p(N), used(N); for(int i=0; i<N; i++) { cin >> p[i]; } int sum = 0; for(int i=0; i<N; i++) { int cnt = 0, idx = i; for(; used[idx] == false; idx = p[idx]) used[idx] = true, cnt++; if(cnt > 0) sum += cnt - 1; } if(sum <= K and K % 2 == sum % 2) cout << "YES" << endl; else cout << "NO" << endl; return 0; }