Submission #566547

# Submission time Handle Problem Language Result Execution time Memory
566547 2022-05-22T11:42:27 Z ac2hu Bali Sculptures (APIO15_sculpture) C++14
46 / 100
1000 ms 6956 KB
#include <bits/stdc++.h>
#ifdef DEBUG
#include "../templates/debug.h"
#else 
#define deb(x...)
#endif
using namespace std;
#define int long long 
struct bag : set<int>{
    void add(int n){
        vector<int> tt;
        for(auto it = begin();it != end();++it){
            int e = *it;
            if((e&n) == e)return;
            if((e&n) == n)tt.push_back(e);
        }
        for(auto e : tt)erase(find(e));
        insert(n);
    }
};
signed main() {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    int n, a, b;cin >> n >> a >> b;
    vector<int> Y(n);
    for(auto &e : Y)cin >> e;
    bag dp[n + 1][n + 1];
    dp[0][0].add(0);
    for(int i = 1;i<=n;i++){
        for(int gsize = 1;gsize<=n;gsize++){
            int tsum = 0;
            for(int j = i;j>=1;j--){
                tsum += Y[j - 1];
                if(dp[j - 1][gsize - 1].size() != 0){
                    for(auto e : dp[j - 1][gsize - 1])
                        dp[i][gsize].add(e|tsum);
                }
            }
        }
    }
    int ans = 1e18;
    for(int i = a;i<=b;i++){
        // deb(i, dp[n][i]);
        if(dp[n][i].size() != 0)
            ans = min(ans, *dp[n][i].begin());
    }
    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 272 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 232 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 4 ms 528 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 3 ms 596 KB Output is correct
31 Correct 7 ms 864 KB Output is correct
32 Correct 4 ms 596 KB Output is correct
33 Correct 4 ms 592 KB Output is correct
34 Correct 11 ms 724 KB Output is correct
35 Correct 5 ms 724 KB Output is correct
36 Correct 8 ms 744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 3 ms 596 KB Output is correct
18 Correct 7 ms 852 KB Output is correct
19 Correct 9 ms 668 KB Output is correct
20 Correct 6 ms 656 KB Output is correct
21 Correct 5 ms 684 KB Output is correct
22 Correct 12 ms 724 KB Output is correct
23 Correct 6 ms 724 KB Output is correct
24 Correct 9 ms 892 KB Output is correct
25 Correct 23 ms 1460 KB Output is correct
26 Correct 47 ms 2204 KB Output is correct
27 Correct 63 ms 2684 KB Output is correct
28 Correct 101 ms 3496 KB Output is correct
29 Correct 45 ms 2540 KB Output is correct
30 Correct 48 ms 2456 KB Output is correct
31 Correct 120 ms 3420 KB Output is correct
32 Correct 114 ms 3640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 2 ms 340 KB Output is correct
30 Correct 4 ms 468 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 4 ms 468 KB Output is correct
40 Correct 3 ms 596 KB Output is correct
41 Correct 19 ms 816 KB Output is correct
42 Correct 4 ms 596 KB Output is correct
43 Correct 4 ms 596 KB Output is correct
44 Correct 7 ms 724 KB Output is correct
45 Correct 5 ms 724 KB Output is correct
46 Correct 6 ms 724 KB Output is correct
47 Correct 9 ms 852 KB Output is correct
48 Correct 40 ms 1392 KB Output is correct
49 Correct 50 ms 2200 KB Output is correct
50 Correct 62 ms 2612 KB Output is correct
51 Correct 103 ms 3388 KB Output is correct
52 Correct 52 ms 2492 KB Output is correct
53 Correct 52 ms 2528 KB Output is correct
54 Correct 104 ms 3376 KB Output is correct
55 Correct 117 ms 3640 KB Output is correct
56 Execution timed out 1063 ms 6956 KB Time limit exceeded
57 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 5 ms 468 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 5 ms 596 KB Output is correct
28 Correct 15 ms 824 KB Output is correct
29 Correct 4 ms 596 KB Output is correct
30 Correct 4 ms 596 KB Output is correct
31 Correct 6 ms 724 KB Output is correct
32 Correct 7 ms 724 KB Output is correct
33 Correct 6 ms 724 KB Output is correct
34 Correct 9 ms 912 KB Output is correct
35 Correct 22 ms 1408 KB Output is correct
36 Correct 43 ms 2184 KB Output is correct
37 Correct 85 ms 2636 KB Output is correct
38 Correct 118 ms 3428 KB Output is correct
39 Correct 54 ms 2480 KB Output is correct
40 Correct 94 ms 2460 KB Output is correct
41 Correct 106 ms 3472 KB Output is correct
42 Correct 137 ms 3664 KB Output is correct
43 Execution timed out 1078 ms 6856 KB Time limit exceeded
44 Halted 0 ms 0 KB -