結果
| 問題 |
No.100 直列あみだくじ
|
| ユーザー |
ey429
|
| 提出日時 | 2015-03-01 12:36:11 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 349 bytes |
| コンパイル時間 | 183 ms |
| コンパイル使用メモリ | 22,912 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-24 00:29:22 |
| 合計ジャッジ時間 | 1,488 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 WA * 7 |
コンパイルメッセージ
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;
}
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){
puts("No");
return 0;
}
}
puts("Yes");
return 0;
}
ey429