Submission #1099934

# Submission time Handle Problem Language Result Execution time Memory
1099934 2024-10-12T07:05:48 Z nnqw Bootfall (IZhO17_bootfall) C++17
13 / 100
1000 ms 604 KB
#include "bits/stdc++.h"
using namespace std;
#define all(v) v.begin(), v.end()
#define ll long long
const int N = 505;
int a[N];

int main() {
    int n;
    scanf("%d", &n);
    for(int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    
    int sm = accumulate(a + 1, a + n + 1, 0);
    vector<int> A;
    
    for(int x = 0; x <= sm; ++x) {
        a[n + 1] = x;  // Tima's fixed strength
        bool done = true;
        
        for(int ad = 1; ad <= n + 1 && done; ++ad) {
            vector<int> v;
            for(int i = 1; i <= n + 1; ++i) {
                if(i != ad)
                    v.push_back(a[i]);
            }
            
            int total = accumulate(all(v), 0);
            if (total % 2 != 0) {
                done = false; // If total is odd, cannot split evenly
                continue;
            }
            
            int half = total / 2;
            vector<bool> dp(half + 1, false);
            dp[0] = true;

            for(int &to : v) {
                for(int i = half; i >= to; --i) {
                    dp[i] = dp[i] || dp[i - to];
                }
            }
            done &= dp[half]; // Check if we can form half
        }
        
        if(done)
            A.push_back(x);
    }
    
    printf("%d\n", (int)A.size());
    for(int i : A)
        printf("%d ", i);
    puts("");
    
    return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
bootfall.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 26 ms 432 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 55 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 26 ms 432 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 55 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 23 ms 348 KB Output is correct
11 Correct 31 ms 436 KB Output is correct
12 Correct 5 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 37 ms 348 KB Output is correct
15 Correct 21 ms 440 KB Output is correct
16 Correct 42 ms 348 KB Output is correct
17 Correct 8 ms 344 KB Output is correct
18 Correct 19 ms 440 KB Output is correct
19 Correct 15 ms 348 KB Output is correct
20 Correct 23 ms 440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 26 ms 432 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 55 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 23 ms 348 KB Output is correct
11 Correct 31 ms 436 KB Output is correct
12 Correct 5 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 37 ms 348 KB Output is correct
15 Correct 21 ms 440 KB Output is correct
16 Correct 42 ms 348 KB Output is correct
17 Correct 8 ms 344 KB Output is correct
18 Correct 19 ms 440 KB Output is correct
19 Correct 15 ms 348 KB Output is correct
20 Correct 23 ms 440 KB Output is correct
21 Execution timed out 1026 ms 348 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 26 ms 432 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 55 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 23 ms 348 KB Output is correct
11 Correct 31 ms 436 KB Output is correct
12 Correct 5 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 37 ms 348 KB Output is correct
15 Correct 21 ms 440 KB Output is correct
16 Correct 42 ms 348 KB Output is correct
17 Correct 8 ms 344 KB Output is correct
18 Correct 19 ms 440 KB Output is correct
19 Correct 15 ms 348 KB Output is correct
20 Correct 23 ms 440 KB Output is correct
21 Execution timed out 1026 ms 348 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 26 ms 432 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 55 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 23 ms 348 KB Output is correct
11 Correct 31 ms 436 KB Output is correct
12 Correct 5 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 37 ms 348 KB Output is correct
15 Correct 21 ms 440 KB Output is correct
16 Correct 42 ms 348 KB Output is correct
17 Correct 8 ms 344 KB Output is correct
18 Correct 19 ms 440 KB Output is correct
19 Correct 15 ms 348 KB Output is correct
20 Correct 23 ms 440 KB Output is correct
21 Execution timed out 1026 ms 348 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 26 ms 432 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 55 ms 348 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 23 ms 348 KB Output is correct
11 Correct 31 ms 436 KB Output is correct
12 Correct 5 ms 348 KB Output is correct
13 Correct 2 ms 348 KB Output is correct
14 Correct 37 ms 348 KB Output is correct
15 Correct 21 ms 440 KB Output is correct
16 Correct 42 ms 348 KB Output is correct
17 Correct 8 ms 344 KB Output is correct
18 Correct 19 ms 440 KB Output is correct
19 Correct 15 ms 348 KB Output is correct
20 Correct 23 ms 440 KB Output is correct
21 Execution timed out 1026 ms 348 KB Time limit exceeded
22 Halted 0 ms 0 KB -