# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
846464 | 2023-09-07T15:06:46 Z | vjudge1 | Bali Sculptures (APIO15_sculpture) | C++17 | 84 ms | 848 KB |
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define task "test1" #define minpos(x, y) (a[x] <= a[y] ? (x) : (y)) #define pll pair<ll, ll> #define pii pair<int, int> using namespace std; int const nmax = 2e3+3; int const mod = 1e9+7; int const LG = 20; int const base=3; void open_file() { if(fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } } void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int n,p,q; int a[nmax]; bool sb1[101][101]; ll sb2[nmax]; ll pre[nmax]; void sub1(){ ll ans=0; for(int bit=40;bit>=0;bit--){ memset(sb1,0,sizeof(sb1)); sb1[0][0]=1; ll tmp=ans|(1ll<<bit); for(int ngan=1;ngan<=q;ngan++){ for(int i=ngan;i<=n;i++){ for(int j=1;j<=i;j++){ ll sum=pre[i]-pre[j-1]; sb1[i][ngan]|=(sb1[j-1][ngan-1] && ((sum&tmp)==0)); } } } for(int i=p;i<=q;i++){ if(sb1[n][i]){ ans|=(1ll<<bit); break; } } } ll res=0; for(int i=0;i<=40;i++){ if(!(ans>>i&1)) res|=(1ll<<i); } cout << res; } void sub2(){ ll ans=0; for(int bit=40;bit>=0;bit--){ memset(sb2,0x3f,sizeof(sb2)); sb2[0]=0; ll tmp=ans|(1ll<<bit); for(int i=1;i<=n;i++){ for(int j=1;j<=i;j++){ ll sum=pre[i]-pre[j-1]; if(sb2[j-1]<1e9 && ((sum&tmp)==0)){ sb2[i]=min(sb2[i],sb2[j-1]+1); } } } if(sb2[n]<=q) ans=tmp; } ll res=0; for(int i=0;i<=40;i++){ if(!(ans>>i&1)) res|=(1ll<<i); } cout << res; } void input() { cin >> n >> p >> q; for(int i=1;i<=n;i++) cin >> a[i],pre[i]=pre[i-1]+a[i]; } void NGU() { if(p!=1) sub1(); else sub2(); } int main() { open_file(); fast(); input(); NGU(); } /* cần càng nhiều bit 0 ở vị trí lớn càng tốt giả sử bit đang xét là 0 minh cần tìm tổng thỏa mãn giữ nguyên các bit lớn hơn nó trước đó đã được xét code sẽ thay đổi vai trò bit 0 và bit 1 bit 0 là đóng vai trò là bit 1 và ngược lại */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 600 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 344 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 344 KB | Output is correct |
13 | Correct | 0 ms | 344 KB | Output is correct |
14 | Correct | 1 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 344 KB | Output is correct |
16 | Correct | 0 ms | 344 KB | Output is correct |
17 | Correct | 1 ms | 344 KB | Output is correct |
18 | Correct | 1 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 344 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 344 KB | Output is correct |
22 | Correct | 1 ms | 344 KB | Output is correct |
23 | Correct | 0 ms | 344 KB | Output is correct |
24 | Correct | 1 ms | 344 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 344 KB | Output is correct |
27 | Correct | 1 ms | 348 KB | Output is correct |
28 | Correct | 0 ms | 344 KB | Output is correct |
29 | Correct | 1 ms | 344 KB | Output is correct |
30 | Correct | 1 ms | 344 KB | Output is correct |
31 | Correct | 0 ms | 344 KB | Output is correct |
32 | Correct | 0 ms | 344 KB | Output is correct |
33 | Correct | 0 ms | 344 KB | Output is correct |
34 | Correct | 0 ms | 344 KB | Output is correct |
35 | Correct | 0 ms | 344 KB | Output is correct |
36 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 344 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 344 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 344 KB | Output is correct |
13 | Correct | 0 ms | 344 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 344 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 344 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 1 ms | 344 KB | Output is correct |
20 | Correct | 0 ms | 344 KB | Output is correct |
21 | Correct | 1 ms | 344 KB | Output is correct |
22 | Correct | 0 ms | 344 KB | Output is correct |
23 | Correct | 0 ms | 344 KB | Output is correct |
24 | Correct | 0 ms | 344 KB | Output is correct |
25 | Correct | 0 ms | 344 KB | Output is correct |
26 | Correct | 1 ms | 344 KB | Output is correct |
27 | Correct | 0 ms | 344 KB | Output is correct |
28 | Correct | 0 ms | 344 KB | Output is correct |
29 | Correct | 1 ms | 344 KB | Output is correct |
30 | Correct | 1 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 344 KB | Output is correct |
32 | Correct | 0 ms | 344 KB | Output is correct |
33 | Correct | 0 ms | 344 KB | Output is correct |
34 | Correct | 0 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 344 KB | Output is correct |
36 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 344 KB | Output is correct |
5 | Correct | 1 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 504 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 344 KB | Output is correct |
14 | Correct | 1 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 344 KB | Output is correct |
16 | Correct | 0 ms | 344 KB | Output is correct |
17 | Correct | 0 ms | 344 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 344 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 1 ms | 344 KB | Output is correct |
22 | Correct | 0 ms | 344 KB | Output is correct |
23 | Correct | 1 ms | 344 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 344 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 0 ms | 344 KB | Output is correct |
28 | Correct | 1 ms | 344 KB | Output is correct |
29 | Correct | 1 ms | 344 KB | Output is correct |
30 | Correct | 1 ms | 344 KB | Output is correct |
31 | Correct | 1 ms | 344 KB | Output is correct |
32 | Correct | 1 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 600 KB | Output is correct |
13 | Correct | 0 ms | 344 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 344 KB | Output is correct |
16 | Correct | 0 ms | 344 KB | Output is correct |
17 | Correct | 0 ms | 344 KB | Output is correct |
18 | Correct | 1 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 344 KB | Output is correct |
20 | Correct | 0 ms | 344 KB | Output is correct |
21 | Correct | 1 ms | 344 KB | Output is correct |
22 | Correct | 1 ms | 344 KB | Output is correct |
23 | Correct | 0 ms | 344 KB | Output is correct |
24 | Correct | 0 ms | 600 KB | Output is correct |
25 | Correct | 0 ms | 344 KB | Output is correct |
26 | Correct | 0 ms | 344 KB | Output is correct |
27 | Correct | 0 ms | 348 KB | Output is correct |
28 | Correct | 0 ms | 344 KB | Output is correct |
29 | Correct | 1 ms | 344 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 344 KB | Output is correct |
32 | Correct | 0 ms | 344 KB | Output is correct |
33 | Correct | 1 ms | 344 KB | Output is correct |
34 | Correct | 0 ms | 344 KB | Output is correct |
35 | Correct | 0 ms | 344 KB | Output is correct |
36 | Correct | 0 ms | 348 KB | Output is correct |
37 | Correct | 0 ms | 344 KB | Output is correct |
38 | Correct | 0 ms | 344 KB | Output is correct |
39 | Correct | 1 ms | 344 KB | Output is correct |
40 | Correct | 0 ms | 344 KB | Output is correct |
41 | Correct | 0 ms | 344 KB | Output is correct |
42 | Correct | 0 ms | 344 KB | Output is correct |
43 | Correct | 1 ms | 344 KB | Output is correct |
44 | Correct | 0 ms | 344 KB | Output is correct |
45 | Correct | 0 ms | 344 KB | Output is correct |
46 | Correct | 0 ms | 344 KB | Output is correct |
47 | Correct | 0 ms | 348 KB | Output is correct |
48 | Correct | 0 ms | 344 KB | Output is correct |
49 | Correct | 1 ms | 348 KB | Output is correct |
50 | Correct | 1 ms | 348 KB | Output is correct |
51 | Correct | 1 ms | 344 KB | Output is correct |
52 | Correct | 1 ms | 344 KB | Output is correct |
53 | Correct | 1 ms | 344 KB | Output is correct |
54 | Correct | 1 ms | 344 KB | Output is correct |
55 | Correct | 1 ms | 344 KB | Output is correct |
56 | Correct | 1 ms | 344 KB | Output is correct |
57 | Correct | 1 ms | 344 KB | Output is correct |
58 | Correct | 1 ms | 344 KB | Output is correct |
59 | Correct | 1 ms | 344 KB | Output is correct |
60 | Correct | 1 ms | 344 KB | Output is correct |
61 | Correct | 1 ms | 600 KB | Output is correct |
62 | Correct | 1 ms | 348 KB | Output is correct |
63 | Correct | 1 ms | 344 KB | Output is correct |
64 | Correct | 12 ms | 344 KB | Output is correct |
65 | Correct | 2 ms | 344 KB | Output is correct |
66 | Correct | 2 ms | 348 KB | Output is correct |
67 | Correct | 4 ms | 344 KB | Output is correct |
68 | Correct | 10 ms | 344 KB | Output is correct |
69 | Correct | 15 ms | 344 KB | Output is correct |
70 | Correct | 16 ms | 344 KB | Output is correct |
71 | Correct | 1 ms | 344 KB | Output is correct |
72 | Correct | 15 ms | 464 KB | Output is correct |
73 | Correct | 14 ms | 344 KB | Output is correct |
74 | Correct | 13 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 600 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 344 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 600 KB | Output is correct |
8 | Correct | 0 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 344 KB | Output is correct |
13 | Correct | 0 ms | 352 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 344 KB | Output is correct |
16 | Correct | 0 ms | 344 KB | Output is correct |
17 | Correct | 0 ms | 344 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 344 KB | Output is correct |
20 | Correct | 1 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 344 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 0 ms | 344 KB | Output is correct |
25 | Correct | 0 ms | 344 KB | Output is correct |
26 | Correct | 0 ms | 344 KB | Output is correct |
27 | Correct | 0 ms | 344 KB | Output is correct |
28 | Correct | 0 ms | 344 KB | Output is correct |
29 | Correct | 0 ms | 344 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 344 KB | Output is correct |
32 | Correct | 0 ms | 348 KB | Output is correct |
33 | Correct | 1 ms | 344 KB | Output is correct |
34 | Correct | 0 ms | 344 KB | Output is correct |
35 | Correct | 0 ms | 344 KB | Output is correct |
36 | Correct | 0 ms | 344 KB | Output is correct |
37 | Correct | 1 ms | 344 KB | Output is correct |
38 | Correct | 1 ms | 344 KB | Output is correct |
39 | Correct | 1 ms | 344 KB | Output is correct |
40 | Correct | 1 ms | 344 KB | Output is correct |
41 | Correct | 1 ms | 344 KB | Output is correct |
42 | Correct | 1 ms | 348 KB | Output is correct |
43 | Correct | 0 ms | 344 KB | Output is correct |
44 | Correct | 1 ms | 344 KB | Output is correct |
45 | Correct | 1 ms | 344 KB | Output is correct |
46 | Correct | 1 ms | 344 KB | Output is correct |
47 | Correct | 1 ms | 344 KB | Output is correct |
48 | Correct | 1 ms | 344 KB | Output is correct |
49 | Correct | 1 ms | 344 KB | Output is correct |
50 | Correct | 1 ms | 548 KB | Output is correct |
51 | Correct | 1 ms | 344 KB | Output is correct |
52 | Correct | 8 ms | 496 KB | Output is correct |
53 | Correct | 12 ms | 344 KB | Output is correct |
54 | Correct | 24 ms | 348 KB | Output is correct |
55 | Correct | 22 ms | 344 KB | Output is correct |
56 | Correct | 68 ms | 344 KB | Output is correct |
57 | Correct | 59 ms | 344 KB | Output is correct |
58 | Correct | 63 ms | 476 KB | Output is correct |
59 | Correct | 74 ms | 344 KB | Output is correct |
60 | Correct | 68 ms | 472 KB | Output is correct |
61 | Correct | 1 ms | 344 KB | Output is correct |
62 | Correct | 9 ms | 344 KB | Output is correct |
63 | Correct | 23 ms | 344 KB | Output is correct |
64 | Correct | 16 ms | 344 KB | Output is correct |
65 | Correct | 33 ms | 848 KB | Output is correct |
66 | Correct | 46 ms | 344 KB | Output is correct |
67 | Correct | 61 ms | 480 KB | Output is correct |
68 | Correct | 84 ms | 344 KB | Output is correct |
69 | Correct | 63 ms | 344 KB | Output is correct |