結果

問題 No.3 ビットすごろく
ユーザー highdhighd
提出日時 2016-08-12 19:52:52
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 702 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 53,976 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 02:37:31
合計ジャッジ時間 1,665 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
5,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 1 ms
5,376 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 2 ms
5,376 KB
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdint>

typedef int_fast16_t int_;
void game(int_*cell,int_ id,int_ max,int_ n){
	if(id>max)return;
	if(id<1)return;
    int_ count = (id & 0x5555) + ((id >> 1) & 0x5555);
    count = (count & 0x3333) + ((count >> 2) & 0x3333);
    count = (count & 0x0f0f) + ((count >> 4) & 0x0f0f);
    count = (count & 0x00ff) + ((count >> 8) & 0x00ff);
	if(id==max){
		cell[id]=n;
		return;
	}
	if(cell[id]==-1||cell[id]<count){
		cell[id]=n;
		game(cell,id+count,max,n+1);
		game(cell,id-count,max,n+1);
	}
}
int main(){
	int_ max;
	std::cin>>max;
	int_*cell=new int_[max+1];
	for(int i=0;i<max+1;i++){
		cell[i]=-1;
	}
	game(cell,1,max,1);
	std::cout<<cell[max];
	delete[] cell;
} 
0