結果
問題 |
No.3 ビットすごろく
|
ユーザー |
![]() |
提出日時 | 2016-01-31 16:37:34 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,020 bytes |
コンパイル時間 | 414 ms |
コンパイル使用メモリ | 56,136 KB |
実行使用メモリ | 10,016 KB |
最終ジャッジ日時 | 2024-09-21 19:41:24 |
合計ジャッジ時間 | 12,736 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 1 -- * 32 |
ソースコード
#include <iostream> using namespace std; int main() { int n, lane, bit, mov; int through[10050]; bool check[10000]; bool flg, hit; cin >> n; flg=true; hit=false; through[0]=1; check[0]=true; for( int i=1; i<n; ++i ){ through[i]=0; check[i]=true; } while( flg ) { for( int i=0; i<n; ++i ) { if( 0<through[i] && check[i] ) { bit=1; for( int j=i+1; 1<j; j>>=1 )bit+=j&1; lane=(i-bit)*(0==i); mov=through[i]+1*(0==i); check[i]=false; through[lane]*=(through[lane]<=mov); flg=(0==through[lane]); while( n-1>lane && 0==through[lane] ) { through[lane]=mov; bit=1; for( int j=lane+1; 1<j; j>>=1 )bit+=j&1; lane+=bit; mov++; through[lane]*=(through[lane]<=mov); } if(n-1==lane) { hit=true; through[n-1]=mov; } } } if(hit)flg=false; } if(!hit)mov=-1; cout << mov << endl; return 0; }