結果

問題 No.3 ビットすごろく
ユーザー highd
提出日時 2016-08-12 19:52:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 702 bytes
コンパイル時間 419 ms
コンパイル使用メモリ 53,848 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-07 12:12:05
合計ジャッジ時間 1,669 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 WA * 15
権限があれば一括ダウンロードができます

ソースコード

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