結果
問題 |
No.100 直列あみだくじ
|
ユーザー |
![]() |
提出日時 | 2015-03-16 17:20:43 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 439 bytes |
コンパイル時間 | 143 ms |
コンパイル使用メモリ | 22,656 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 23:06:31 |
合計ジャッジ時間 | 1,104 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 WA * 16 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%d", &N); | ~~~~~^~~~~~~~~~ main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d", A+i); | ~~~~~^~~~~~~~~~~
ソースコード
#include <cstdio> int N, A[51]; bool used[51]; int main(){ scanf("%d", &N); for(int i=1;i<=N;i++){ scanf("%d", A+i); } int n2 = 0, n4 = 0; for(int i=1;i<=N;i++){ if(used[i]){continue;} int t = 1; for(int j=A[i];j!=i;j=A[j]){used[j] = true; t++;} if(t == 2){n2++;} else if(t % 2 == 0){n4++;} } if(n2 % 2 == 0 || n4 > 0){puts("Yes");} else{puts("No");} }