結果
問題 | No.3 ビットすごろく |
ユーザー | mannshi222jp |
提出日時 | 2022-02-07 22:29:44 |
言語 | C (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,498 bytes |
コンパイル時間 | 779 ms |
コンパイル使用メモリ | 29,908 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-04 13:37:57 |
合計ジャッジ時間 | 21,736 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,376 KB |
testcase_03 | WA | - |
testcase_04 | AC | 8 ms
4,376 KB |
testcase_05 | WA | - |
testcase_06 | AC | 99 ms
4,380 KB |
testcase_07 | AC | 34 ms
4,380 KB |
testcase_08 | AC | 248 ms
4,380 KB |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | AC | 374 ms
4,380 KB |
testcase_13 | WA | - |
testcase_14 | AC | 897 ms
4,376 KB |
testcase_15 | AC | 1,403 ms
4,380 KB |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | AC | 43 ms
4,380 KB |
testcase_19 | RE | - |
testcase_20 | AC | 4 ms
4,380 KB |
testcase_21 | AC | 0 ms
4,376 KB |
testcase_22 | RE | - |
testcase_23 | AC | 1,437 ms
4,384 KB |
testcase_24 | RE | - |
testcase_25 | AC | 1,397 ms
4,380 KB |
testcase_26 | AC | 0 ms
4,376 KB |
testcase_27 | AC | 70 ms
4,380 KB |
testcase_28 | AC | 1,154 ms
4,380 KB |
testcase_29 | RE | - |
testcase_30 | AC | 1 ms
4,380 KB |
testcase_31 | AC | 1 ms
4,380 KB |
testcase_32 | RE | - |
ソースコード
#include <stdio.h> int bit( int i ); int setstep( int *idou, int i, int step, int N ); int main() { int N; int idou[10000+1]; int bits; scanf("%d\n", &N ); for( int i; i < 10000+1; i++ ) { idou[i] = 0; } idou[1] = 1; setstep( idou, 1-bit(1), idou[1]+1, N ); setstep( idou, 1+bit(1), idou[1]+1, N ); /**/ /* for( int i = 0; i <= N; i++ ) { printf("%d %d\n", i, idou[i] ); } /**/ if( idou[N] == 0 ) { printf("-1\n"); } else { printf("%d\n", idou[N]); } return 0; } int setstep( int *idou, int i, int step, int N ) { if( step > N ) { return 0; } if( i <= 0 ) { return 0; } if( idou[i] == 0 ) { idou[i] = step; setstep( idou, i-bit(i), idou[i]+1, N ); setstep( idou, i+bit(i), idou[i]+1, N ); return 0; } if( idou[i] > step ) { idou[i] = step; setstep( idou, i-bit(i), idou[i]+1, N ); if( i+ bit(i) <= N ) { setstep( idou, i+bit(i), idou[i]+1, N ); } } return 0; } int bit( int i ){ int num = 0; int mask = 1; for ( ; mask != 0 ; mask = mask << 1 ){ if (i & mask ) num++; } return num; }