結果

問題 No.2071 Shift and OR
ユーザー 👑 p-adicp-adic
提出日時 2022-09-17 09:11:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,098 bytes
コンパイル時間 2,023 ms
コンパイル使用メモリ 199,536 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 17:30:08
合計ジャッジ時間 3,629 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

using uint = unsigned int;
using ll = long long;

#define CIN( LL , A ) LL A; cin >> A 
#define GETLINE( A ) string A; getline( cin , A ) 
#define GETLINE_SEPARATE( A , SEPARATOR ) string A; getline( cin , A , SEPARATOR ) 
#define UNTIE ios_base::sync_with_stdio( false ); cin.tie( nullptr ) 
#define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( ll VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) 
#define FOR_ITR( ARRAY , ITR , END ) for( auto ITR = ARRAY .begin() , END = ARRAY .end() ; ITR != END ; ITR ++ ) 
#define REPEAT( HOW_MANY_TIMES ) FOR( VARIABLE_FOR_REPEAT , 0 , HOW_MANY_TIMES ) 
#define RETURN( ANSWER ) cout << ( ANSWER ) << "\n"; return 0 
#define DOUBLE( PRECISION , ANSWER ) cout << fixed << setprecision( PRECISION ) << ( ANSWER ) << "\n"; return 0 
#define MIN( A , B ) A < B ? A : B;
#define MAX( A , B ) A < B ? B : A;

template <typename T> inline T Absolute( const T& a ){ return a > 0 ? a : - a; }

int main()
{
  UNTIE;
  CIN( ll , N );
  constexpr const ll power = 65536;
  constexpr const ll digit = 16;
  if( N >= digit ){
    RETURN( power - 1 );
  }
  bool c[power] = {};
  ll answer[power];
  ll size = 0;
  ll size_new = 0;
  ll Ai;
  constexpr const ll shift = power / 2;
  {
    cin >> Ai;
    REPEAT( digit ){
      if( ! c[Ai] ){
      	c[Ai] = true;
      	answer[size_new] = Ai;
      	size_new++;
      }
      Ai = shift * ( Ai % 2 ) + Ai / 2;
    }
    size = size_new;
  }
  N--;
  ll answer_new;
  FOR( i , 1 , N ){
    cin >> Ai;
    size_new = size;
    REPEAT( digit ){
      FOR( j , 0 , size ){
	answer_new = answer[j] | Ai;
	if( ! c[answer_new] ){
	  c[answer_new] = true;
	  answer[size_new] = answer_new;
	  size_new++;
	}
      }
      Ai = shift * ( Ai % 2 ) + Ai / 2;
    }
    size = size_new;
  }
  ll max = -1;
  {
    cin >> Ai;
    REPEAT( digit ){
      FOR( j , 0 , size ){
  	answer_new = answer[j] | Ai;
	if( c[answer_new] ){
	  if( max < answer_new ){
	    max = answer_new;
	  }
	}
      }
      Ai = shift * ( Ai % 2 ) + Ai / 2;
    }
  }
  RETURN( max );
}

0