답안 #487323

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
487323 2021-11-15T07:18:10 Z leaked Bali Sculptures (APIO15_sculpture) C++14
71 / 100
453 ms 262148 KB
#include <bits/stdc++.h>

#define f first
#define s second
#define pb push_back
#define vec vector
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pw(x) (1LL<<(x))
#define fast_iati ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;
template <class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);}
template <class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N=2e3+2;
const int lg=61;
const ll inf=1e18;
int dp1[N],n,a,b;
bitset<N> dp[N];
bitset<N> go[N];
ll pref[N];
ll get(int l,int r){
    return pref[r]-(l?pref[l-1]:0);
}
bool check(vec<pii> &e){
    for(int i=0;i<n;i++) go[i].reset();
    for(auto &z : e) go[z.f][z.s]=1;
    if(n>500){
        for(int i=0;i<=n;i++) dp1[i]=1e9;
        dp1[0]=0;
        for(int i=0;i<n;i++){
            for(int j=0;j<=i;j++){
                if(go[i][j])
                    umin(dp1[i+1],dp1[j]+1);
            }
        }
        return (dp1[n]<=b);
    }
    else{
        for(int i=0;i<=n;i++){
            dp[i].reset();
        }
        dp[0][0]=1;
        for(int i=0;i<n;i++){
            for(int cnt=n;cnt>=0;cnt--){
                int is=(dp[cnt]&go[i]).count();
                if(is)
                    dp[cnt+1][i+1]=1;
            }
        }
        int ok=0;
        for(int i=a;i<=b;i++)
            ok|=(dp[i][n]==1);
        return ok;
    }
}
ll rec(int b,vec<pii> &e,ll x){
    if(!check(e)) return -inf;
//    cout<<"OK "<<b<<' '<<x<<endl;
//    for(auto &z : e)
//        cout<<z.f<<' '<<z.s<<endl;
    if(b==0) return x;
    vec<pii> lft;
    for(auto &z : e){
        ll w=get(z.s,z.f);
        w>>=(b-1);w<<=(b-1);
        if((w|x)==x)
            lft.pb(z);
    }
    ll w=rec(b-1,lft,x);
    if(w!=-inf) return w;
    return rec(b-1,e,x+pw(b-1));
}
signed main(){
    fast_iati;
    cin>>n>>a>>b;
    for(int i=0;i<n;i++){
        cin>>pref[i];
        if(i)
            pref[i]+=pref[i-1];
    }
    vec<pii> e;
    for(int i=0;i<n;i++){
        for(int j=i;j<n;j++)
            e.pb({j,i});
    }
    cout<<rec(lg,e,0);
    return 0;
}
/*
6 1 3
8 1 2 1 5 4

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 336 KB Output is correct
2 Correct 2 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 5 ms 320 KB Output is correct
7 Correct 3 ms 464 KB Output is correct
8 Correct 4 ms 464 KB Output is correct
9 Correct 3 ms 336 KB Output is correct
10 Correct 3 ms 464 KB Output is correct
11 Correct 3 ms 464 KB Output is correct
12 Correct 4 ms 464 KB Output is correct
13 Correct 3 ms 368 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 2 ms 336 KB Output is correct
20 Correct 3 ms 448 KB Output is correct
21 Correct 4 ms 464 KB Output is correct
22 Correct 5 ms 336 KB Output is correct
23 Correct 3 ms 336 KB Output is correct
24 Correct 3 ms 336 KB Output is correct
25 Correct 3 ms 464 KB Output is correct
26 Correct 5 ms 436 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 2 ms 376 KB Output is correct
30 Correct 4 ms 336 KB Output is correct
31 Correct 4 ms 336 KB Output is correct
32 Correct 3 ms 336 KB Output is correct
33 Correct 3 ms 416 KB Output is correct
34 Correct 4 ms 336 KB Output is correct
35 Correct 4 ms 336 KB Output is correct
36 Correct 4 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 3 ms 464 KB Output is correct
8 Correct 4 ms 464 KB Output is correct
9 Correct 4 ms 464 KB Output is correct
10 Correct 3 ms 464 KB Output is correct
11 Correct 6 ms 464 KB Output is correct
12 Correct 3 ms 464 KB Output is correct
13 Correct 4 ms 464 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 2 ms 336 KB Output is correct
20 Correct 3 ms 336 KB Output is correct
21 Correct 3 ms 464 KB Output is correct
22 Correct 4 ms 464 KB Output is correct
23 Correct 3 ms 432 KB Output is correct
24 Correct 3 ms 464 KB Output is correct
25 Correct 4 ms 464 KB Output is correct
26 Correct 3 ms 408 KB Output is correct
27 Correct 4 ms 464 KB Output is correct
28 Correct 6 ms 464 KB Output is correct
29 Correct 11 ms 736 KB Output is correct
30 Correct 19 ms 708 KB Output is correct
31 Correct 20 ms 1224 KB Output is correct
32 Correct 18 ms 1228 KB Output is correct
33 Correct 19 ms 1236 KB Output is correct
34 Correct 18 ms 1236 KB Output is correct
35 Correct 19 ms 1228 KB Output is correct
36 Correct 18 ms 1204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 3 ms 452 KB Output is correct
8 Correct 4 ms 464 KB Output is correct
9 Correct 4 ms 464 KB Output is correct
10 Correct 3 ms 464 KB Output is correct
11 Correct 4 ms 464 KB Output is correct
12 Correct 4 ms 464 KB Output is correct
13 Correct 3 ms 464 KB Output is correct
14 Correct 5 ms 336 KB Output is correct
15 Correct 5 ms 464 KB Output is correct
16 Correct 11 ms 720 KB Output is correct
17 Correct 13 ms 808 KB Output is correct
18 Correct 19 ms 1148 KB Output is correct
19 Correct 20 ms 1228 KB Output is correct
20 Correct 29 ms 1196 KB Output is correct
21 Correct 19 ms 1228 KB Output is correct
22 Correct 19 ms 1128 KB Output is correct
23 Correct 19 ms 1244 KB Output is correct
24 Correct 19 ms 1228 KB Output is correct
25 Correct 30 ms 1392 KB Output is correct
26 Correct 43 ms 1828 KB Output is correct
27 Correct 58 ms 2248 KB Output is correct
28 Correct 70 ms 2644 KB Output is correct
29 Correct 103 ms 2624 KB Output is correct
30 Correct 75 ms 2832 KB Output is correct
31 Correct 88 ms 2704 KB Output is correct
32 Correct 78 ms 2660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 2 ms 328 KB Output is correct
7 Correct 3 ms 336 KB Output is correct
8 Correct 4 ms 452 KB Output is correct
9 Correct 3 ms 336 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 3 ms 464 KB Output is correct
12 Correct 3 ms 464 KB Output is correct
13 Correct 4 ms 456 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 3 ms 336 KB Output is correct
20 Correct 3 ms 464 KB Output is correct
21 Correct 4 ms 464 KB Output is correct
22 Correct 4 ms 464 KB Output is correct
23 Correct 3 ms 336 KB Output is correct
24 Correct 5 ms 448 KB Output is correct
25 Correct 3 ms 464 KB Output is correct
26 Correct 4 ms 464 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Correct 2 ms 336 KB Output is correct
29 Correct 2 ms 336 KB Output is correct
30 Correct 4 ms 336 KB Output is correct
31 Correct 4 ms 336 KB Output is correct
32 Correct 4 ms 336 KB Output is correct
33 Correct 4 ms 336 KB Output is correct
34 Correct 4 ms 340 KB Output is correct
35 Correct 5 ms 336 KB Output is correct
36 Correct 5 ms 464 KB Output is correct
37 Correct 4 ms 464 KB Output is correct
38 Correct 6 ms 464 KB Output is correct
39 Correct 11 ms 720 KB Output is correct
40 Correct 13 ms 712 KB Output is correct
41 Correct 19 ms 1212 KB Output is correct
42 Correct 23 ms 1168 KB Output is correct
43 Correct 22 ms 1248 KB Output is correct
44 Correct 19 ms 1228 KB Output is correct
45 Correct 20 ms 1228 KB Output is correct
46 Correct 18 ms 1256 KB Output is correct
47 Correct 19 ms 1172 KB Output is correct
48 Correct 30 ms 1440 KB Output is correct
49 Correct 44 ms 1868 KB Output is correct
50 Correct 58 ms 2240 KB Output is correct
51 Correct 69 ms 2716 KB Output is correct
52 Correct 67 ms 2700 KB Output is correct
53 Correct 77 ms 2816 KB Output is correct
54 Correct 72 ms 2628 KB Output is correct
55 Correct 71 ms 2628 KB Output is correct
56 Correct 26 ms 716 KB Output is correct
57 Correct 59 ms 1228 KB Output is correct
58 Correct 82 ms 1420 KB Output is correct
59 Correct 98 ms 1992 KB Output is correct
60 Correct 79 ms 1488 KB Output is correct
61 Correct 80 ms 1604 KB Output is correct
62 Correct 93 ms 1732 KB Output is correct
63 Correct 94 ms 1812 KB Output is correct
64 Correct 53 ms 2216 KB Output is correct
65 Correct 26 ms 832 KB Output is correct
66 Correct 42 ms 964 KB Output is correct
67 Correct 58 ms 1180 KB Output is correct
68 Correct 80 ms 1400 KB Output is correct
69 Correct 96 ms 1604 KB Output is correct
70 Correct 78 ms 1520 KB Output is correct
71 Correct 80 ms 1652 KB Output is correct
72 Correct 100 ms 1728 KB Output is correct
73 Correct 96 ms 1776 KB Output is correct
74 Correct 95 ms 1812 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 3 ms 336 KB Output is correct
8 Correct 3 ms 464 KB Output is correct
9 Correct 3 ms 464 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 5 ms 464 KB Output is correct
12 Correct 4 ms 464 KB Output is correct
13 Correct 3 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 2 ms 324 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 4 ms 336 KB Output is correct
18 Correct 4 ms 336 KB Output is correct
19 Correct 4 ms 336 KB Output is correct
20 Correct 4 ms 328 KB Output is correct
21 Correct 4 ms 364 KB Output is correct
22 Correct 4 ms 464 KB Output is correct
23 Correct 4 ms 464 KB Output is correct
24 Correct 4 ms 464 KB Output is correct
25 Correct 5 ms 464 KB Output is correct
26 Correct 11 ms 720 KB Output is correct
27 Correct 14 ms 784 KB Output is correct
28 Correct 19 ms 1228 KB Output is correct
29 Correct 19 ms 1208 KB Output is correct
30 Correct 19 ms 1156 KB Output is correct
31 Correct 18 ms 1228 KB Output is correct
32 Correct 19 ms 1228 KB Output is correct
33 Correct 19 ms 1236 KB Output is correct
34 Correct 19 ms 1208 KB Output is correct
35 Correct 31 ms 1392 KB Output is correct
36 Correct 43 ms 1860 KB Output is correct
37 Correct 58 ms 2216 KB Output is correct
38 Correct 70 ms 2704 KB Output is correct
39 Correct 69 ms 2684 KB Output is correct
40 Correct 73 ms 2852 KB Output is correct
41 Correct 69 ms 2644 KB Output is correct
42 Correct 70 ms 2628 KB Output is correct
43 Correct 26 ms 716 KB Output is correct
44 Correct 60 ms 1168 KB Output is correct
45 Correct 80 ms 1392 KB Output is correct
46 Correct 94 ms 1604 KB Output is correct
47 Correct 96 ms 1640 KB Output is correct
48 Correct 85 ms 1624 KB Output is correct
49 Correct 121 ms 1732 KB Output is correct
50 Correct 96 ms 1740 KB Output is correct
51 Correct 119 ms 1588 KB Output is correct
52 Correct 82 ms 34748 KB Output is correct
53 Correct 128 ms 56508 KB Output is correct
54 Correct 206 ms 100004 KB Output is correct
55 Correct 205 ms 99564 KB Output is correct
56 Runtime error 453 ms 262148 KB Execution killed with signal 9
57 Halted 0 ms 0 KB -