結果
問題 |
No.482 あなたの名は
|
ユーザー |
|
提出日時 | 2017-02-13 01:02:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 70 ms / 2,000 ms |
コード長 | 271 bytes |
コンパイル時間 | 556 ms |
コンパイル使用メモリ | 64,676 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-29 20:38:56 |
合計ジャッジ時間 | 3,051 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 9 | main() | ^~~~
ソースコード
#include<iostream> using namespace std; long k;int c,n,d[1<<18],u[1<<18]; void dfs(int v) { if(u[v])k-=c-1; else u[v]=1,c++,dfs(d[v]); } main() { cin>>n>>k; for(int i=1;i<=n;i++)cin>>d[i]; for(int i=1;i<=n;i++)if(!u[i])c=0,dfs(i); cout<<(k<0||k%2?"NO\n":"YES\n"); }