結果

問題 No.2071 Shift and OR
ユーザー HIcoderHIcoder
提出日時 2023-07-11 14:48:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,122 bytes
コンパイル時間 1,123 ms
コンパイル使用メモリ 106,020 KB
実行使用メモリ 8,708 KB
最終ジャッジ日時 2023-10-11 05:55:47
合計ジャッジ時間 5,596 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,708 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 4 ms
4,352 KB
testcase_03 AC 733 ms
4,348 KB
testcase_04 AC 44 ms
4,352 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=998244353;
const double PI=acos(-1);


void printbit(int n){

    if(n==0) cout<<"0"<<endl; 
    vector<int> c;
    while(n>0){
        c.push_back(n%2);
        n/=2;
    }

    reverse(c.begin(),c.end());
    for(int v:c){
        cout<<v;
    }
    cout<<endl;
}

int shift(int x){
    
    return (((x%2)<<15) + (x/2));
}

int bithead(int x){
    int cnt=0;
    while(x>0){
        cnt++;
        x/=2;
    }
    return cnt;
}

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }

    if(N>=15){
        //鳩ノ巣原理
        //A[i]のどれかはbit1が立っているので 1を15個連続して立たせることが可能
        int ans=(1<<16)-1;
        cout<<ans<<endl;
    }else{

        /*
        int ans=0;

        int c=15;//2^15
        
        for(int i=0;i<N;i++){
            ans|=1<<c;
            c--;

           

        }

        cout<<ans<<endl;
        */

       //全探索で処理
       int ans=0;

        auto dfs=[&](auto f,int idx,int num)->void{
            if(idx==N){
                ans=max(ans,num);
                return;
            }

            
            for(int c=0;c<15;c++){
                f(f,idx+1,num|A[idx]);
                A[idx]=shift(A[idx]);
            }
        };

        dfs(dfs,0,0);

        cout<<ans<<endl;



        /*
        int ans=0;
        int c=15;//2^15
        for(int i=0;i<N;i++){
            
            cout<<"i="<<i<<endl;
            int n=A[i];

            while(( (n>>c)&1)==0){
                n=shift(n);
                //cout<<"n="<<n<<endl;
            }
            
            
            printbit(n);

            ans|=n;
            cout<<"ans="<<ans<<endl;
            printbit(ans);
            c--;
        }

        cout<<ans<<endl;
        */


    }
  
}
0