結果

問題 No.973 余興
ユーザー mugen_1337mugen_1337
提出日時 2021-04-14 17:20:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,713 bytes
コンパイル時間 2,115 ms
コンパイル使用メモリ 207,220 KB
実行使用メモリ 199,184 KB
最終ジャッジ日時 2023-09-13 06:52:14
合計ジャッジ時間 24,475 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 539 ms
198,880 KB
testcase_01 WA -
testcase_02 AC 546 ms
198,880 KB
testcase_03 AC 532 ms
198,876 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 538 ms
198,936 KB
testcase_07 WA -
testcase_08 AC 541 ms
198,076 KB
testcase_09 AC 541 ms
198,968 KB
testcase_10 AC 509 ms
191,248 KB
testcase_11 WA -
testcase_12 AC 196 ms
73,852 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 13 ms
11,024 KB
testcase_16 AC 14 ms
11,220 KB
testcase_17 AC 7 ms
8,052 KB
testcase_18 AC 9 ms
9,364 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 13 ms
10,912 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 16 ms
12,216 KB
testcase_28 AC 9 ms
9,336 KB
testcase_29 WA -
testcase_30 AC 652 ms
198,904 KB
testcase_31 AC 642 ms
198,876 KB
testcase_32 AC 637 ms
198,880 KB
testcase_33 AC 638 ms
198,876 KB
testcase_34 AC 674 ms
198,176 KB
testcase_35 WA -
testcase_36 AC 660 ms
193,912 KB
testcase_37 AC 661 ms
193,864 KB
testcase_38 AC 658 ms
198,552 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 2 ms
4,380 KB
testcase_42 AC 1 ms
4,380 KB
testcase_43 AC 1 ms
4,376 KB
testcase_44 AC 2 ms
4,380 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 637 ms
198,876 KB
testcase_49 AC 578 ms
183,752 KB
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 651 ms
195,432 KB
testcase_54 WA -
testcase_55 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:53:21: 警告: ‘j’ may be used uninitialized [-Wmaybe-uninitialized]
   53 |             t_l[i]=j-1;
      |                    ~^~
main.cpp:48:17: 備考: ‘j’ はここで定義されています
   48 |             int j;
      |                 ^

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define ALL(x) begin(x),end(x)
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 998244353
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}
template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}



signed main(){
    int n;ll x;cin>>n>>x;
    vector<ll> v(n);
    cin>>v;
    vector<int> t_l(n),t_r(n);// can take [i, t_l[i]], [t_r[i], i]
    
    vector<ll> s(n);
    s[0]=v[0];
    for(int i=1;i<n;i++) s[i]=s[i-1]+v[i];

    for(int i=0;i<n;i++){
        {
            ll sum=0;
            int j;
            for(int j=i;j<n;j++){
                sum+=v[j];
                if(sum>x) break;
            }
            t_l[i]=j-1;
        }
        {
            ll sum=0;
            int j;
            for(j=i;j>=0;j--){
                sum+=v[j];
                if(sum>x) break;
            }
            t_r[i]=j+1;
        }
    }


    for(int i=0;i<n;i++){
        ll sum=0;
        for(int j=i;j<=t_l[i];j++) sum+=v[j];
        assert(sum<=x);
    }

    for(int i=0;i<n;i++){
        ll sum=0;
        for(int j=t_r[i];j<=i;j++) sum+=v[j];
        // assert(sum<=x);
    }

    vector<vector<int>> L(n+2,vector<int>(n+2,0)),R(n+2,vector<int>(n+2,0));
    rep(i,n) L[i][i]=1,R[i][i]=1;

    auto getL=[&](int R,int l,int r){
        int ret=L[l][R];
        if(r+1<=n) ret-=L[r+1][R];
        return ret;
    };
    auto getR=[&](int L,int l,int r){
        int ret=R[L][r];
        if(l) ret-=R[L][l-1];
        return ret;
    };

    bool res=false;
    for(int w=2;w<=n;w++){
        for(int l=0;l+w<=n;l++){
            int r=l+w-1;

            bool win=false;
            int a=t_l[l];// can eat [l,a]
            int b=t_r[r];// [b,r]

            if(getL(r,l+1,a+1)) win=true;
            if(getR(l,b-1,r-1)) win=true;

            L[l][r]=L[l+1][r];
            R[l][r]=R[l][r-1];
            if(!win){
                L[l][r]++;
                R[l][r]++;
            }
            if(l==0 and r==n-1) res=win;
        }
    }
    cout<<("BA"[res])<<endl;
    return 0;
}
0