結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2017-05-07 21:09:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 619 bytes |
コンパイル時間 | 533 ms |
コンパイル使用メモリ | 59,100 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-14 14:51:22 |
合計ジャッジ時間 | 1,967 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #define SIZE 30 using std::vector; using std::cin; using std::cout; using std::endl; using std::sort; int main() { std::cin.tie(0);std::ios::sync_with_stdio(false); int64_t n; int64_t k; int d[200001] = {}; int b[200001] = {}; cin >> n; cin >> k; int64_t inp; int64_t count=0; for(int i=1;i<=n;++i){ cin>>d[i]; } for(int i=1;i<=n;++i){ if(b[i]==0){ b[i]=1; int j = i; while(d[j]!=i){ j = d[j]; count++; b[j]=1; } } } if(count > k || count%2 != k%2){ cout << "NO"; }else{ cout << "YES"; } return 0; }