結果

問題 No.1246 ANDORゲーム(max)
ユーザー 👑 tute7627tute7627
提出日時 2020-08-01 05:10:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,315 bytes
コンパイル時間 2,468 ms
コンパイル使用メモリ 208,924 KB
実行使用メモリ 152,744 KB
最終ジャッジ日時 2023-10-12 21:23:39
合計ジャッジ時間 13,457 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define rep(i,n,m) for(int i = (n); i < (int)(m); i++)
#define rrep(i,n,m) for(int i = (m) - 1; i >= (int)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const int INF = (int)1e9+1;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
template<typename T>
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
int main(){
  int n,t;
  cin>>n>>t;
  vector<int>a(n);
  rep(i,0,n)cin>>a[i];
  vector<unordered_map<int,int>>dp(n+1);
  dp[0][t]=0;
  rep(i,0,n){
    auto ope=[&](pair<int,int>pre,int cmd){
      pair<int,int>nxt=pre;
      if(cmd==0)nxt.first&=a[i];
      else nxt.first|=a[i];
      if(pre.first<nxt.first)nxt.second+=2;
      if(pre.first>nxt.first)nxt.second-=1;
      return nxt;
    };
    for(auto p:dp[i]){
      rep(j,0,2){
        auto nxt=ope(p,j);
        if(dp[i+1].count(nxt.first))chmax(dp[i+1][nxt.first],nxt.second);
        else dp[i+1][nxt.first]=nxt.second;
      }
    }
  }
  int ret=-INF;
  for(auto p:dp[n])chmax(ret,p.second);
  cout<<ret<<endl;
  return 0;
}
0