結果
問題 | No.973 余興 |
ユーザー | Enjapma_kyopro |
提出日時 | 2020-01-18 12:27:25 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2,307 ms / 4,000 ms |
コード長 | 5,454 bytes |
コンパイル時間 | 1,644 ms |
コンパイル使用メモリ | 173,160 KB |
実行使用メモリ | 353,536 KB |
最終ジャッジ日時 | 2024-06-27 06:03:53 |
合計ジャッジ時間 | 77,418 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2,072 ms
353,408 KB |
testcase_01 | AC | 2,047 ms
353,408 KB |
testcase_02 | AC | 2,030 ms
353,408 KB |
testcase_03 | AC | 2,029 ms
353,152 KB |
testcase_04 | AC | 2,056 ms
353,536 KB |
testcase_05 | AC | 2,039 ms
353,408 KB |
testcase_06 | AC | 2,035 ms
353,408 KB |
testcase_07 | AC | 2,006 ms
353,280 KB |
testcase_08 | AC | 2,039 ms
352,384 KB |
testcase_09 | AC | 2,038 ms
353,408 KB |
testcase_10 | AC | 1,934 ms
341,632 KB |
testcase_11 | AC | 740 ms
144,896 KB |
testcase_12 | AC | 714 ms
145,024 KB |
testcase_13 | AC | 704 ms
143,744 KB |
testcase_14 | AC | 715 ms
143,872 KB |
testcase_15 | AC | 63 ms
27,264 KB |
testcase_16 | AC | 64 ms
27,648 KB |
testcase_17 | AC | 38 ms
20,224 KB |
testcase_18 | AC | 49 ms
23,680 KB |
testcase_19 | AC | 50 ms
23,808 KB |
testcase_20 | AC | 38 ms
19,968 KB |
testcase_21 | AC | 62 ms
27,392 KB |
testcase_22 | AC | 62 ms
27,264 KB |
testcase_23 | AC | 50 ms
23,936 KB |
testcase_24 | AC | 49 ms
23,552 KB |
testcase_25 | AC | 23 ms
14,848 KB |
testcase_26 | AC | 38 ms
19,840 KB |
testcase_27 | AC | 71 ms
30,080 KB |
testcase_28 | AC | 49 ms
23,680 KB |
testcase_29 | AC | 48 ms
23,552 KB |
testcase_30 | AC | 2,307 ms
353,536 KB |
testcase_31 | AC | 2,292 ms
353,408 KB |
testcase_32 | AC | 2,286 ms
353,408 KB |
testcase_33 | AC | 2,240 ms
353,408 KB |
testcase_34 | AC | 2,258 ms
352,384 KB |
testcase_35 | AC | 2,269 ms
353,408 KB |
testcase_36 | AC | 2,185 ms
345,472 KB |
testcase_37 | AC | 2,227 ms
345,728 KB |
testcase_38 | AC | 2,256 ms
352,512 KB |
testcase_39 | AC | 2,231 ms
352,768 KB |
testcase_40 | AC | 2 ms
5,376 KB |
testcase_41 | AC | 2 ms
5,376 KB |
testcase_42 | AC | 2 ms
5,376 KB |
testcase_43 | AC | 2 ms
5,376 KB |
testcase_44 | AC | 2 ms
5,376 KB |
testcase_45 | AC | 3 ms
5,376 KB |
testcase_46 | AC | 2,187 ms
353,280 KB |
testcase_47 | AC | 2,166 ms
353,152 KB |
testcase_48 | AC | 2,193 ms
353,408 KB |
testcase_49 | AC | 2,009 ms
329,984 KB |
testcase_50 | AC | 2,199 ms
351,232 KB |
testcase_51 | AC | 2,200 ms
353,408 KB |
testcase_52 | AC | 2,276 ms
353,408 KB |
testcase_53 | AC | 2,263 ms
348,160 KB |
testcase_54 | AC | 2,279 ms
353,408 KB |
testcase_55 | AC | 2,269 ms
353,280 KB |
ソースコード
#include <bits/stdc++.h> #include <unistd.h> using namespace std; typedef long long ll; typedef pair<ll,ll> P; long long int INF = 3e18; const ll fact_table = 800008; double Pi = 3.1415926535897932384626; //vector<ll> G[550010]; //vector<P> tree[500010]; priority_queue <ll> pql; priority_queue <P> pqp; //big priority queue priority_queue <ll,vector<ll>,greater<ll> > pqls; // priority_queue <P,vector<P>,greater<P> > pqps; //small priority queue //top pop ll dx[8]={1,0,-1,0,1,1,-1,-1}; ll dy[8]={0,1,0,-1,1,-1,-1,1}; char dir[] = "DRUL"; //ll bit[500005]; //↓,→,↑,← #define p(x) cout<<x<<"\n"; #define el cout<<endl; #define pe(x) cout<<(x)<<" "; #define ps(x) cout<<fixed<<setprecision(25)<<x<<endl; #define pu(x) cout<<(x); #define pb push_back #define lb lower_bound #define ub upper_bound #define CLEAR(a) a = decltype(a)(); //ll mod = 998244353; ll mod = 1000000007; ll rui(ll number1,ll number2){ if(number2 == 0){ return 1; }else{ ll number3 = rui(number1,number2 / 2); number3 *= number3; number3 %= mod; if(number2%2==1){ number3 *= number1; number3 %= mod; } return number3; } } ll gcd(ll number1,ll number2){ if(number1 > number2){ swap(number1,number2); } if(number1 == 0 || number1 == number2){ return number2; }else{ return gcd(number2 % number1,number1); } } void YES(bool condition){ if(condition){ p("YES"); }else{ p("NO"); } return; } void Yes(bool condition){ if(condition){ p("Yes"); }else{ p("No"); } return; } /* ll fact[fact_table + 5],rfact[fact_table + 5]; void c3_init(){ fact[0] = rfact[0] = 1; for(ll i=1; i<=fact_table; i++){ fact[i] = (fact[i-1]*i) % mod; } rfact[fact_table] = rui(fact[fact_table],mod - 2); for(ll i=fact_table; i>=1; i--){ rfact[i-1] = rfact[i] * i; rfact[i-1] %= mod; } return;} ll c3(ll n,ll r){ return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;} */ ll n,m,num,sum,a,b,c,d,e,g,h,w, i,j,q,r,l; ll k; ll ans; ll x[500005], y[200005], z[200005]; // char s[500005], t[500005]; bool used[3005][3004]; ll dp[5004][5004]; ll sum_l[5005][5005]; ll sum_r[5005][5005]; char s[2005][2005]; ll ruiseki(ll l, ll r){ return y[r] - y[l]; } ll solve(ll i, ll j){ // pe(i);p(j); // dp[i][j]の結果を求める if(dp[i][j] != 0)return dp[i][j]; if(i == j){ dp[i][j] = 2; return 2; } ll l, r; l = i; r = j; vector<ll> v; for(ll i=l+1;i<=r;i++){ // 左を食べる if(ruiseki(l, i) <= k)v.pb(solve(i, r)); } for(ll i=l;i<r;i++){ // 右を食べる if(ruiseki(i+1, r+1) <= k)v.pb(solve(l, i)); } bool canwin = false; for(ll i=0;i<v.size();i++){ if(v[i] == 2)canwin = true; } if(canwin){ dp[i][j] = 1; return 1; }else{ dp[i][j] = 2; return 2; } } int main(){ /* cin.tie(0); ios::sync_with_stdio(false); */ cin >> n >> k; for(ll i=0;i<n;i++){ cin >> x[i]; } for(ll i=0;i<n;i++){ y[i+1] = x[i]; } for(ll i=0;i<n;i++){ y[i+2] += y[i+1]; } for(ll l=0;l<n;l++){ for(ll i=0;i+l<n;i++){ ll j = i + l; bool canwin = false; // dp[i][j]はどうなるか? if(i == j){ dp[i][j] = 2; sum_l[i][j] = 2; sum_r[i][j] = 2; continue; } // 左から食べる場合 ll ok = i, ng = j + 2; while(ng - ok > 1){ ll mid = (ok + ng) / 2; if(ruiseki(i, mid) <= k){ ok = mid; }else{ ng = mid; } } if(ok >= j){ canwin = true; } // ruiseki(i, ok) <= k ll tmp1 = sum_l[i+1][j] - sum_l[ok+1][j]; ll kosuu1 = ok - i; assert(tmp1 >= kosuu1); if(tmp1 > kosuu1){ // 負けへの遷移がある canwin = true; } // 右から食べる場合 ok = j+1, ng = i - 1; while(ok - ng > 1){ ll mid = (ok + ng) / 2; if(ruiseki(mid, j+1) <= k){ ok = mid; }else{ ng = mid; } } if(ok <= i + 1){ canwin = true; } ll tmp2 = sum_r[i][j-1] - sum_r[i][ok-2]; ll kosuu2 = j - ok + 1; assert(tmp2 >= kosuu2); assert(kosuu2 * 2 >= tmp2); if(tmp2 > kosuu2){ // 負けへの遷移がある canwin = true; } if(canwin){ dp[i][j] = 1; }else{ dp[i][j] = 2; } sum_r[i][j] = sum_r[i][j-1] + dp[i][j]; sum_l[i][j] = sum_l[i+1][j] + dp[i][j]; } } for(ll i=0;i<n;i++){ for(ll j=0;j<n;j++){ //pe(dp[i][j]); // pe(sum_r[i][j]); } //el; } if(dp[0][n-1] == 2){ p("B"); }else{ p("A"); } return 0; }