Submission #107107

# Submission time Handle Problem Language Result Execution time Memory
107107 2019-04-22T01:45:36 Z tduong0806 Bali Sculptures (APIO15_sculpture) C++14
100 / 100
86 ms 1016 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define min(a,b) ((a)<(b)?(a):(b))
#define forv(a,b) for(auto &a:b)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define reset(f,x) memset(f,x,sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define onbit(x,i) (x|(1ll<<(i-1)))
#define offbit(x,i) (x&~(1<<(i-1)))
#define read2(a,b) read(a),read(b)
#define read3(a,b,c) read(a),read(b),read(c)
const int N=2010;
int n,A,B,F[N],a[N];
ll f[N][N],s[N],kq;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("SCULPTURE.inp","r",stdin);
    //freopen("SCULPTURE.out","w",stdout);
    cin>>n>>A>>B;
    forinc(i,1,n) cin>>a[i],s[i]=s[i-1]+a[i];
    if(n<=100)
    {
        ll S=0;
        f[0][0]=1;
        fordec(i,41,1)
        {
            ll tg=onbit(S,i);
            forinc(i,1,n) forinc(j,1,B)
            {
                f[i][j]=0;
                forinc(t,0,i-1) if(!(tg&(s[i]-s[t]))&&f[t][j-1]) f[i][j]=1;
            }
            bool ok=0;
            forinc(i,A,B) if(f[n][i]) ok=1;
            if(ok) S=tg;
            else kq=onbit(kq,i);
        }
        return cout<<kq,0;
    }
    ll S=0;
    F[0]=0;
    fordec(i,41,1)
    {
        ll tg=onbit(S,i);
        forinc(i,1,n)
        {
            F[i]=1e4;
            forinc(j,0,i-1) if(!(tg&(s[i]-s[j]))) F[i]=min(F[i],F[j]+1);
        }
        if(F[n]<=B) S=tg;
        else kq=onbit(kq,i);
    }
    return cout<<kq,0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 2 ms 512 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 4 ms 384 KB Output is correct
31 Correct 3 ms 512 KB Output is correct
32 Correct 2 ms 512 KB Output is correct
33 Correct 3 ms 384 KB Output is correct
34 Correct 0 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 432 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 3 ms 512 KB Output is correct
23 Correct 2 ms 512 KB Output is correct
24 Correct 2 ms 512 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 5 ms 512 KB Output is correct
28 Correct 3 ms 512 KB Output is correct
29 Correct 3 ms 512 KB Output is correct
30 Correct 3 ms 512 KB Output is correct
31 Correct 5 ms 512 KB Output is correct
32 Correct 4 ms 512 KB Output is correct
33 Correct 2 ms 512 KB Output is correct
34 Correct 5 ms 640 KB Output is correct
35 Correct 4 ms 512 KB Output is correct
36 Correct 3 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 2 ms 512 KB Output is correct
14 Correct 3 ms 512 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 512 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
18 Correct 4 ms 512 KB Output is correct
19 Correct 4 ms 512 KB Output is correct
20 Correct 2 ms 512 KB Output is correct
21 Correct 5 ms 512 KB Output is correct
22 Correct 4 ms 512 KB Output is correct
23 Correct 3 ms 512 KB Output is correct
24 Correct 1 ms 668 KB Output is correct
25 Correct 5 ms 640 KB Output is correct
26 Correct 8 ms 640 KB Output is correct
27 Correct 22 ms 796 KB Output is correct
28 Correct 30 ms 768 KB Output is correct
29 Correct 30 ms 896 KB Output is correct
30 Correct 3 ms 768 KB Output is correct
31 Correct 15 ms 768 KB Output is correct
32 Correct 32 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 3 ms 512 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 512 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
29 Correct 3 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 512 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 3 ms 512 KB Output is correct
35 Correct 2 ms 512 KB Output is correct
36 Correct 3 ms 512 KB Output is correct
37 Correct 3 ms 384 KB Output is correct
38 Correct 3 ms 384 KB Output is correct
39 Correct 3 ms 512 KB Output is correct
40 Correct 4 ms 512 KB Output is correct
41 Correct 4 ms 640 KB Output is correct
42 Correct 4 ms 512 KB Output is correct
43 Correct 2 ms 512 KB Output is correct
44 Correct 4 ms 640 KB Output is correct
45 Correct 4 ms 640 KB Output is correct
46 Correct 3 ms 512 KB Output is correct
47 Correct 4 ms 512 KB Output is correct
48 Correct 3 ms 640 KB Output is correct
49 Correct 10 ms 640 KB Output is correct
50 Correct 16 ms 768 KB Output is correct
51 Correct 33 ms 896 KB Output is correct
52 Correct 30 ms 896 KB Output is correct
53 Correct 3 ms 768 KB Output is correct
54 Correct 16 ms 768 KB Output is correct
55 Correct 24 ms 768 KB Output is correct
56 Correct 4 ms 512 KB Output is correct
57 Correct 8 ms 640 KB Output is correct
58 Correct 14 ms 768 KB Output is correct
59 Correct 27 ms 768 KB Output is correct
60 Correct 24 ms 896 KB Output is correct
61 Correct 3 ms 768 KB Output is correct
62 Correct 28 ms 888 KB Output is correct
63 Correct 27 ms 768 KB Output is correct
64 Correct 21 ms 768 KB Output is correct
65 Correct 4 ms 512 KB Output is correct
66 Correct 4 ms 640 KB Output is correct
67 Correct 6 ms 640 KB Output is correct
68 Correct 17 ms 768 KB Output is correct
69 Correct 33 ms 768 KB Output is correct
70 Correct 29 ms 768 KB Output is correct
71 Correct 3 ms 768 KB Output is correct
72 Correct 25 ms 896 KB Output is correct
73 Correct 20 ms 896 KB Output is correct
74 Correct 18 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 512 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 2 ms 512 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 2 ms 512 KB Output is correct
18 Correct 2 ms 356 KB Output is correct
19 Correct 2 ms 512 KB Output is correct
20 Correct 2 ms 484 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 2 ms 256 KB Output is correct
23 Correct 3 ms 512 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 3 ms 512 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 4 ms 512 KB Output is correct
28 Correct 4 ms 512 KB Output is correct
29 Correct 5 ms 640 KB Output is correct
30 Correct 3 ms 512 KB Output is correct
31 Correct 4 ms 512 KB Output is correct
32 Correct 4 ms 512 KB Output is correct
33 Correct 4 ms 512 KB Output is correct
34 Correct 4 ms 640 KB Output is correct
35 Correct 4 ms 640 KB Output is correct
36 Correct 7 ms 640 KB Output is correct
37 Correct 15 ms 768 KB Output is correct
38 Correct 33 ms 896 KB Output is correct
39 Correct 31 ms 896 KB Output is correct
40 Correct 3 ms 768 KB Output is correct
41 Correct 17 ms 768 KB Output is correct
42 Correct 24 ms 860 KB Output is correct
43 Correct 5 ms 640 KB Output is correct
44 Correct 8 ms 640 KB Output is correct
45 Correct 14 ms 768 KB Output is correct
46 Correct 25 ms 1016 KB Output is correct
47 Correct 22 ms 896 KB Output is correct
48 Correct 3 ms 768 KB Output is correct
49 Correct 24 ms 896 KB Output is correct
50 Correct 25 ms 768 KB Output is correct
51 Correct 3 ms 384 KB Output is correct
52 Correct 10 ms 384 KB Output is correct
53 Correct 16 ms 384 KB Output is correct
54 Correct 29 ms 384 KB Output is correct
55 Correct 25 ms 384 KB Output is correct
56 Correct 86 ms 504 KB Output is correct
57 Correct 80 ms 504 KB Output is correct
58 Correct 74 ms 384 KB Output is correct
59 Correct 77 ms 384 KB Output is correct
60 Correct 85 ms 384 KB Output is correct
61 Correct 3 ms 384 KB Output is correct
62 Correct 14 ms 384 KB Output is correct
63 Correct 26 ms 408 KB Output is correct
64 Correct 23 ms 384 KB Output is correct
65 Correct 42 ms 448 KB Output is correct
66 Correct 63 ms 384 KB Output is correct
67 Correct 82 ms 384 KB Output is correct
68 Correct 84 ms 384 KB Output is correct
69 Correct 83 ms 384 KB Output is correct