Submission #566526

# Submission time Handle Problem Language Result Execution time Memory
566526 2022-05-22T11:29:39 Z ac2hu Bali Sculptures (APIO15_sculpture) C++14
21 / 100
1000 ms 3008 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<pair<int,int>>{
    void add(int n, int temp){
        for(auto it = begin();it!=end();++it){
            auto [e, val] = *it;
            if(((e&n) == e) && temp >= val)return;
        }
        insert({n, temp});
    }
};
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];
    dp[0].add(0, 0);
    for(int i = 1;i<=n;i++){
        int tsum = 0;
        for(int j = i;j>=1;j--){
            tsum += Y[j - 1];
            if(dp[j - 1].size() != 0){
                for(auto [e, val] : dp[j - 1]){
                    if(val < b){
                        dp[i].add(e|tsum, val + 1);
                    }
                }
            }
        }
    }
    deb(dp[n]);
    cout << (*dp[n].begin()).first << "\n";
}

Compilation message

sculpture.cpp: In member function 'void bag::add(long long int, long long int)':
sculpture.cpp:12:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   12 |             auto [e, val] = *it;
      |                  ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:31:26: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   31 |                 for(auto [e, val] : dp[j - 1]){
      |                          ^
# 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 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Incorrect 1 ms 212 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 248 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 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 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Incorrect 0 ms 212 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 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 1 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 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 4 ms 340 KB Output is correct
18 Correct 20 ms 468 KB Output is correct
19 Correct 8 ms 340 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 7 ms 340 KB Output is correct
22 Correct 8 ms 468 KB Output is correct
23 Correct 10 ms 484 KB Output is correct
24 Correct 15 ms 468 KB Output is correct
25 Correct 32 ms 612 KB Output is correct
26 Correct 114 ms 920 KB Output is correct
27 Correct 167 ms 1000 KB Output is correct
28 Correct 217 ms 1212 KB Output is correct
29 Correct 103 ms 844 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 317 ms 1416 KB Output is correct
32 Correct 345 ms 1500 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 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 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Incorrect 0 ms 212 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 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 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 4 ms 340 KB Output is correct
28 Correct 14 ms 448 KB Output is correct
29 Correct 7 ms 340 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 6 ms 448 KB Output is correct
32 Correct 7 ms 468 KB Output is correct
33 Correct 8 ms 456 KB Output is correct
34 Correct 14 ms 560 KB Output is correct
35 Correct 38 ms 596 KB Output is correct
36 Correct 104 ms 928 KB Output is correct
37 Correct 135 ms 1060 KB Output is correct
38 Correct 209 ms 1292 KB Output is correct
39 Correct 96 ms 928 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 319 ms 1408 KB Output is correct
42 Correct 349 ms 1500 KB Output is correct
43 Execution timed out 1087 ms 3008 KB Time limit exceeded
44 Halted 0 ms 0 KB -