結果

問題 No.1246 ANDORゲーム(max)
ユーザー 👑 tute7627tute7627
提出日時 2020-08-04 18:17:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,764 bytes
コンパイル時間 2,208 ms
コンパイル使用メモリ 204,256 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-12 21:28:45
合計ジャッジ時間 4,277 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,348 KB
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 41 ms
4,352 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 30 ms
4,348 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘std::pair<int, long long int> ope(std::pair<int, long long int>, int, int)’ 内:
main.cpp:23:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   23 | }
      | ^

ソースコード

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};
pair<int,ll> ope(pair<int,ll> now,int val,int cmd){
  if(cmd==0)return make_pair(now.first|val,now.second+abs((now.first|val)-now.first));
  if(cmd==1)return make_pair(now.first&val,now.second+abs((now.first&val)-now.first));
}
ll solve1(ll n,ll t,vector<int>&a){
  pair<int,ll>p(t,0);
  rep(i,0,n){
    auto nxt0=ope(p,a[i],0);
    auto nxt1=ope(p,a[i],1);
    if(nxt0.second<nxt1.second)swap(nxt0,nxt1);
    p=nxt0;
  }
  return p.second;
}
ll solve4(ll n,ll t,vector<int>&a){
  pair<int,ll>p(t,0);
  rep(i,0,n){
    auto nxt0=ope(p,a[i],1);
    auto nxt1=ope(p,a[i],0);
    if(nxt0.second<nxt1.second)swap(nxt0,nxt1);
    p=nxt0;
  }
  return p.second;
}
ll solve2(ll n,ll t,vector<int>&a){
  pair<int,ll>p(t,0);
  rep(i,0,n){
    p=ope(p,a[i],i&1);
  }
  return p.second;
}
ll solve3(ll n,ll t,vector<int>&a){
  pair<int,ll>p(t,0);
  rep(i,0,n){
    p=ope(p,a[i],~i&1);
  }
  return p.second;
}

int main(){
  int n,t;
  cin>>n>>t;
  vector<int>a(n);
  rep(i,0,n)cin>>a[i];
  ll ret=0;
  chmax(ret,solve1(n,t,a));
  chmax(ret,solve2(n,t,a));
  chmax(ret,solve3(n,t,a));
  chmax(ret,solve4(n,t,a));
  cout<<ret<<endl;
  return 0;
}
0