結果

問題 No.1255 ハイレーツ・オブ・ボリビアン
ユーザー beetbeet
提出日時 2020-10-09 22:03:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,304 bytes
コンパイル時間 2,139 ms
コンパイル使用メモリ 199,852 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-09-27 17:07:22
合計ジャッジ時間 5,856 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,528 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 7 ms
4,376 KB
testcase_06 AC 10 ms
4,376 KB
testcase_07 AC 8 ms
4,376 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=Int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}


vector<Int> identity(Int n){
  vector<Int> ord(n);
  iota(ord.begin(),ord.end(),0);
  return ord;
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  auto solve=[](Int n){
    Int res=0,tmp=1;
    do{
      tmp+=2*n-1;
      while(tmp%2==0) tmp/=2,res++;
    }while(tmp!=1);
    return res;
  };

  auto naive=[&](Int n){
    vector<Int> as=identity(2*n);
    Int cnt=0;
    do{
      cnt++;
      vector<Int> bs(as);
      for(Int i=0;i<n;i++){
        as[i*2+0]=bs[0+i];
        as[i*2+1]=bs[n+i];
      }
    }while(as!=identity(2*n));
    return cnt;
  };

  const Int EXPERIMENT = 0;
  if(EXPERIMENT){
    for(Int n=1;n<=30;n++){
      cout<<n<<':'<<naive(n)<<':'<<solve(n)<<newl;
      assert(naive(n)==solve(n));
    }
  }

  Int T;
  cin>>T;
  while(T--){
    Int n;
    cin>>n;
    cout<<solve(n)<<newl;
  }
  return 0;
}
0