結果
問題 |
No.3 ビットすごろく
|
ユーザー |
![]() |
提出日時 | 2016-01-31 14:05:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 849 bytes |
コンパイル時間 | 475 ms |
コンパイル使用メモリ | 54,720 KB |
実行使用メモリ | 10,144 KB |
最終ジャッジ日時 | 2024-09-21 19:40:01 |
合計ジャッジ時間 | 12,874 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 1 -- * 32 |
ソースコード
#include <iostream> using namespace std; int main() { int n, locate, bitcount, movenum; int road[10000], through[10000]; cin >> n; locate=0; movenum=99999; for( int i=0; i<n; ++i )through[i]=0; for( int i=0; i<n; ++i ) { if( n==locate+1 ) { if(movenum>i+1)movenum=i+1; } road[i]=locate; through[locate]=1; if(0==through[locate])for(int j=locate+1; j>1; j>>=1)through[locate]+=j&1; if(n-1<locate+through[locate] || 0<through[locate+through[locate]]) { if(0>locate-through[locate] || 0<through[locate-through[locate]]) { if(1==road[i-1])i=n; else{ locate=road[i-1]; i--; } } else locate-=through[locate]; } else locate+=through[locate]; } if(movenum>10000)movenum=-1; cout << movenum << endl; return 0; }