結果
問題 |
No.100 直列あみだくじ
|
ユーザー |
![]() |
提出日時 | 2015-03-01 12:37:52 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 351 bytes |
コンパイル時間 | 154 ms |
コンパイル使用メモリ | 23,040 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 00:29:23 |
合計ジャッジ時間 | 1,404 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 WA * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:9:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d",&nxt[i]); | ~~~~~^~~~~~~~~~~~~~
ソースコード
#include<stdio.h> int nxt[50]; bool used[50]; int main(){ int n,i; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d",&nxt[i]); nxt[i]--; used[i]=false; } int t=0; for(i=0;i<n;i++)if(!used[i]){ int v=i; int s=0; while(!used[v]){ used[v]=true; s++; v=nxt[v]; } if(s%2==0)t++; } printf("%s\n",t%2==0?"Yes":"No"); return 0; }