結果

問題 No.2071 Shift and OR
ユーザー akuaakua
提出日時 2022-09-16 22:52:08
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 1,873 bytes
コンパイル時間 3,516 ms
コンパイル使用メモリ 179,024 KB
実行使用メモリ 7,504 KB
最終ジャッジ日時 2023-08-23 16:23:07
合計ジャッジ時間 6,294 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
4,380 KB
testcase_01 AC 12 ms
4,400 KB
testcase_02 AC 20 ms
4,956 KB
testcase_03 AC 25 ms
5,380 KB
testcase_04 AC 23 ms
5,176 KB
testcase_05 AC 37 ms
6,232 KB
testcase_06 AC 23 ms
5,200 KB
testcase_07 AC 19 ms
4,892 KB
testcase_08 AC 24 ms
5,236 KB
testcase_09 AC 23 ms
5,344 KB
testcase_10 AC 23 ms
5,160 KB
testcase_11 AC 41 ms
6,488 KB
testcase_12 AC 41 ms
6,504 KB
testcase_13 AC 37 ms
6,292 KB
testcase_14 AC 5 ms
4,376 KB
testcase_15 AC 28 ms
5,644 KB
testcase_16 AC 30 ms
5,772 KB
testcase_17 AC 40 ms
6,532 KB
testcase_18 AC 12 ms
4,392 KB
testcase_19 AC 45 ms
6,768 KB
testcase_20 AC 44 ms
6,740 KB
testcase_21 AC 54 ms
7,504 KB
testcase_22 AC 47 ms
6,964 KB
testcase_23 AC 17 ms
4,376 KB
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 9 ms
4,376 KB
testcase_26 AC 10 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 18 ms
4,380 KB
testcase_29 AC 18 ms
4,380 KB
testcase_30 AC 26 ms
5,632 KB
testcase_31 AC 26 ms
5,392 KB
testcase_32 AC 27 ms
5,496 KB
testcase_33 AC 26 ms
5,400 KB
testcase_34 AC 26 ms
5,608 KB
testcase_35 AC 27 ms
5,392 KB
testcase_36 AC 27 ms
5,396 KB
testcase_37 AC 26 ms
5,360 KB
testcase_38 AC 26 ms
5,360 KB
testcase_39 AC 27 ms
5,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;  
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
const ll inf=1e18+1;  
using graph = vector<vector<int> > ;
using P= pair<ll,ll>;  
using vi=vector<int>;
using vvi=vector<vi>;
using vll=vector<ll>; 
using vvll=vector<vll>;
using vp=vector<P>;
using vpp=vector<vp>;
//string T="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//string S="abcdefghijklmnopqrstuvwxyz";
//g++ main.cpp -std=c++14 -I .  
//cout <<setprecision(20);
//cout << fixed << setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);
const double PI = acos(-1);

int main(){cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  vi a(n);rep(i,n)cin >> a[i];
  ll Bit=1ll<<16;
  if(n>=16){
    ll ans=Bit-1;
    cout << ans << endl;
    return 0;
  }
  auto f=[&](int i){
    return i/2+(1<<15)*(i&1);
  };
  vvi dp(n+1,vi(Bit));
  dp[0][0]=1;
  rep(i,n)rep(j,Bit){
    rep(k,17){
      a[i]=f(a[i]);
      int nj=j|a[i];
      dp[i+1][nj]|=dp[i][j];
    }
  }
  int ans=0;
  rep(i,Bit)if(dp[n][i])ans=i;
  cout << ans << endl;
  
}

0