結果
問題 |
No.482 あなたの名は
|
ユーザー |
![]() |
提出日時 | 2017-02-15 01:22:17 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 699 bytes |
コンパイル時間 | 637 ms |
コンパイル使用メモリ | 53,880 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-29 22:49:41 |
合計ジャッジ時間 | 2,427 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d%lld",&N,&K); | ~~~~~^~~~~~~~~~~~~~~~ main.cpp:14:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | scanf("%d", &d); | ~~~~~^~~~~~~~~~
ソースコード
#include <iostream> using namespace std; typedef long long ll; const int _N = 2e5+8; int N; ll K; int D[_N]; bool p[_N]={false}; int main(void){ scanf("%d%lld",&N,&K); for(int i=0;i<N;i++){ int d; scanf("%d", &d); d--; D[i]=d; } ll sum = 0; int cnt=0,sumd=0; for(int i=0;i<N;i++){ int next=0; while(next<N){ if(p[next]){ cnt++; next = cnt; }else{ p[next] = true; next = D[next]; sumd++; if(p[next]){ sumd--; sum+=sumd; sumd=0; // cnt++; // next = cnt; } } } } printf("%s",(K<sum || (K-sum) % 2) ? "NO" : "YES"); return 0; }