Submission #507215

# Submission time Handle Problem Language Result Execution time Memory
507215 2022-01-12T09:42:00 Z dannyboy20031204 Bootfall (IZhO17_bootfall) C++17
44 / 100
1000 ms 1744 KB
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define mp make_pair
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
using namespace std;
void db() {cout << endl;}
template <typename T, typename ...U> void db(T a, U ...b) {cout << a << ' ', db(b...);}
#ifdef Cloud
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#else
#define file ios::sync_with_stdio(false); cin.tie(0)
#endif
#define pii pair<int, int>
const int inf = 1e9, N = 250001, mod = 998244353;
int main(){
    file;
    int n;
    cin >> n;
    int a[n], tot = 0, cnt[N]{};
    for (int &i : a) cin >> i, tot += i;
    if (tot % 2) return cout << 0 << '\n', 0;
    bitset<250001> dp;
    for (int s = -1; s < n; s++){
        dp.reset();
        dp.flip(0);
        dp[0] = 1;
        for (int i = 0; i < n; i++){
            if (i == s) continue;
            dp |= dp << a[i];
            //for (int j = 0; j <= 20; j++) db(i, j, dp[j]);
        }
        if (s == -1 and !dp[tot / 2]) return cout << 0 << '\n', 0;
        if (s >= 0) for (int i = 0; i < N; i++){
            if (dp[i] and i * 2 - tot + a[s] > 0) cnt[i * 2 - tot + a[s]]++;
        }
    }
    vector<int> v;
    for (int i = 1; i < N; i++) if (cnt[i] == n) v.push_back(i);
    cout << v.size() << '\n';
    for (int i : v) cout << i << ' ';
    //db("ya");
}

Compilation message

bootfall.cpp:7: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    7 | #pragma GCC optimization ("O3")
      |
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1356 KB Output is correct
2 Correct 4 ms 1356 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 3 ms 1356 KB Output is correct
5 Correct 8 ms 1356 KB Output is correct
6 Correct 4 ms 1356 KB Output is correct
7 Correct 3 ms 1356 KB Output is correct
8 Correct 6 ms 1356 KB Output is correct
9 Correct 7 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1356 KB Output is correct
2 Correct 4 ms 1356 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 3 ms 1356 KB Output is correct
5 Correct 8 ms 1356 KB Output is correct
6 Correct 4 ms 1356 KB Output is correct
7 Correct 3 ms 1356 KB Output is correct
8 Correct 6 ms 1356 KB Output is correct
9 Correct 7 ms 1356 KB Output is correct
10 Correct 18 ms 1356 KB Output is correct
11 Correct 20 ms 1376 KB Output is correct
12 Correct 22 ms 1356 KB Output is correct
13 Correct 13 ms 1376 KB Output is correct
14 Correct 20 ms 1372 KB Output is correct
15 Correct 20 ms 1376 KB Output is correct
16 Correct 22 ms 1360 KB Output is correct
17 Correct 13 ms 1372 KB Output is correct
18 Correct 17 ms 1356 KB Output is correct
19 Correct 16 ms 1356 KB Output is correct
20 Correct 15 ms 1376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1356 KB Output is correct
2 Correct 4 ms 1356 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 3 ms 1356 KB Output is correct
5 Correct 8 ms 1356 KB Output is correct
6 Correct 4 ms 1356 KB Output is correct
7 Correct 3 ms 1356 KB Output is correct
8 Correct 6 ms 1356 KB Output is correct
9 Correct 7 ms 1356 KB Output is correct
10 Correct 18 ms 1356 KB Output is correct
11 Correct 20 ms 1376 KB Output is correct
12 Correct 22 ms 1356 KB Output is correct
13 Correct 13 ms 1376 KB Output is correct
14 Correct 20 ms 1372 KB Output is correct
15 Correct 20 ms 1376 KB Output is correct
16 Correct 22 ms 1360 KB Output is correct
17 Correct 13 ms 1372 KB Output is correct
18 Correct 17 ms 1356 KB Output is correct
19 Correct 16 ms 1356 KB Output is correct
20 Correct 15 ms 1376 KB Output is correct
21 Correct 69 ms 1368 KB Output is correct
22 Correct 65 ms 1364 KB Output is correct
23 Correct 31 ms 1376 KB Output is correct
24 Correct 81 ms 1356 KB Output is correct
25 Correct 92 ms 1368 KB Output is correct
26 Correct 120 ms 1360 KB Output is correct
27 Correct 142 ms 1356 KB Output is correct
28 Correct 110 ms 1356 KB Output is correct
29 Correct 105 ms 1356 KB Output is correct
30 Correct 129 ms 1360 KB Output is correct
31 Correct 107 ms 1356 KB Output is correct
32 Correct 99 ms 1364 KB Output is correct
33 Correct 89 ms 1356 KB Output is correct
34 Correct 104 ms 1356 KB Output is correct
35 Correct 107 ms 1356 KB Output is correct
36 Correct 109 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1356 KB Output is correct
2 Correct 4 ms 1356 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 3 ms 1356 KB Output is correct
5 Correct 8 ms 1356 KB Output is correct
6 Correct 4 ms 1356 KB Output is correct
7 Correct 3 ms 1356 KB Output is correct
8 Correct 6 ms 1356 KB Output is correct
9 Correct 7 ms 1356 KB Output is correct
10 Correct 18 ms 1356 KB Output is correct
11 Correct 20 ms 1376 KB Output is correct
12 Correct 22 ms 1356 KB Output is correct
13 Correct 13 ms 1376 KB Output is correct
14 Correct 20 ms 1372 KB Output is correct
15 Correct 20 ms 1376 KB Output is correct
16 Correct 22 ms 1360 KB Output is correct
17 Correct 13 ms 1372 KB Output is correct
18 Correct 17 ms 1356 KB Output is correct
19 Correct 16 ms 1356 KB Output is correct
20 Correct 15 ms 1376 KB Output is correct
21 Correct 69 ms 1368 KB Output is correct
22 Correct 65 ms 1364 KB Output is correct
23 Correct 31 ms 1376 KB Output is correct
24 Correct 81 ms 1356 KB Output is correct
25 Correct 92 ms 1368 KB Output is correct
26 Correct 120 ms 1360 KB Output is correct
27 Correct 142 ms 1356 KB Output is correct
28 Correct 110 ms 1356 KB Output is correct
29 Correct 105 ms 1356 KB Output is correct
30 Correct 129 ms 1360 KB Output is correct
31 Correct 107 ms 1356 KB Output is correct
32 Correct 99 ms 1364 KB Output is correct
33 Correct 89 ms 1356 KB Output is correct
34 Correct 104 ms 1356 KB Output is correct
35 Correct 107 ms 1356 KB Output is correct
36 Correct 109 ms 1356 KB Output is correct
37 Correct 422 ms 1480 KB Output is correct
38 Correct 361 ms 1484 KB Output is correct
39 Correct 588 ms 1356 KB Output is correct
40 Correct 846 ms 1476 KB Output is correct
41 Correct 655 ms 1356 KB Output is correct
42 Correct 599 ms 1484 KB Output is correct
43 Correct 627 ms 1740 KB Output is correct
44 Correct 546 ms 1644 KB Output is correct
45 Correct 544 ms 1740 KB Output is correct
46 Correct 635 ms 1356 KB Output is correct
47 Correct 532 ms 1488 KB Output is correct
48 Correct 587 ms 1612 KB Output is correct
49 Correct 512 ms 1356 KB Output is correct
50 Correct 595 ms 1484 KB Output is correct
51 Correct 1 ms 1356 KB Output is correct
52 Correct 706 ms 1744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1356 KB Output is correct
2 Correct 4 ms 1356 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 3 ms 1356 KB Output is correct
5 Correct 8 ms 1356 KB Output is correct
6 Correct 4 ms 1356 KB Output is correct
7 Correct 3 ms 1356 KB Output is correct
8 Correct 6 ms 1356 KB Output is correct
9 Correct 7 ms 1356 KB Output is correct
10 Correct 18 ms 1356 KB Output is correct
11 Correct 20 ms 1376 KB Output is correct
12 Correct 22 ms 1356 KB Output is correct
13 Correct 13 ms 1376 KB Output is correct
14 Correct 20 ms 1372 KB Output is correct
15 Correct 20 ms 1376 KB Output is correct
16 Correct 22 ms 1360 KB Output is correct
17 Correct 13 ms 1372 KB Output is correct
18 Correct 17 ms 1356 KB Output is correct
19 Correct 16 ms 1356 KB Output is correct
20 Correct 15 ms 1376 KB Output is correct
21 Correct 69 ms 1368 KB Output is correct
22 Correct 65 ms 1364 KB Output is correct
23 Correct 31 ms 1376 KB Output is correct
24 Correct 81 ms 1356 KB Output is correct
25 Correct 92 ms 1368 KB Output is correct
26 Correct 120 ms 1360 KB Output is correct
27 Correct 142 ms 1356 KB Output is correct
28 Correct 110 ms 1356 KB Output is correct
29 Correct 105 ms 1356 KB Output is correct
30 Correct 129 ms 1360 KB Output is correct
31 Correct 107 ms 1356 KB Output is correct
32 Correct 99 ms 1364 KB Output is correct
33 Correct 89 ms 1356 KB Output is correct
34 Correct 104 ms 1356 KB Output is correct
35 Correct 107 ms 1356 KB Output is correct
36 Correct 109 ms 1356 KB Output is correct
37 Correct 422 ms 1480 KB Output is correct
38 Correct 361 ms 1484 KB Output is correct
39 Correct 588 ms 1356 KB Output is correct
40 Correct 846 ms 1476 KB Output is correct
41 Correct 655 ms 1356 KB Output is correct
42 Correct 599 ms 1484 KB Output is correct
43 Correct 627 ms 1740 KB Output is correct
44 Correct 546 ms 1644 KB Output is correct
45 Correct 544 ms 1740 KB Output is correct
46 Correct 635 ms 1356 KB Output is correct
47 Correct 532 ms 1488 KB Output is correct
48 Correct 587 ms 1612 KB Output is correct
49 Correct 512 ms 1356 KB Output is correct
50 Correct 595 ms 1484 KB Output is correct
51 Correct 1 ms 1356 KB Output is correct
52 Correct 706 ms 1744 KB Output is correct
53 Correct 849 ms 1616 KB Output is correct
54 Execution timed out 1006 ms 1736 KB Time limit exceeded
55 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1356 KB Output is correct
2 Correct 4 ms 1356 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 3 ms 1356 KB Output is correct
5 Correct 8 ms 1356 KB Output is correct
6 Correct 4 ms 1356 KB Output is correct
7 Correct 3 ms 1356 KB Output is correct
8 Correct 6 ms 1356 KB Output is correct
9 Correct 7 ms 1356 KB Output is correct
10 Correct 18 ms 1356 KB Output is correct
11 Correct 20 ms 1376 KB Output is correct
12 Correct 22 ms 1356 KB Output is correct
13 Correct 13 ms 1376 KB Output is correct
14 Correct 20 ms 1372 KB Output is correct
15 Correct 20 ms 1376 KB Output is correct
16 Correct 22 ms 1360 KB Output is correct
17 Correct 13 ms 1372 KB Output is correct
18 Correct 17 ms 1356 KB Output is correct
19 Correct 16 ms 1356 KB Output is correct
20 Correct 15 ms 1376 KB Output is correct
21 Correct 69 ms 1368 KB Output is correct
22 Correct 65 ms 1364 KB Output is correct
23 Correct 31 ms 1376 KB Output is correct
24 Correct 81 ms 1356 KB Output is correct
25 Correct 92 ms 1368 KB Output is correct
26 Correct 120 ms 1360 KB Output is correct
27 Correct 142 ms 1356 KB Output is correct
28 Correct 110 ms 1356 KB Output is correct
29 Correct 105 ms 1356 KB Output is correct
30 Correct 129 ms 1360 KB Output is correct
31 Correct 107 ms 1356 KB Output is correct
32 Correct 99 ms 1364 KB Output is correct
33 Correct 89 ms 1356 KB Output is correct
34 Correct 104 ms 1356 KB Output is correct
35 Correct 107 ms 1356 KB Output is correct
36 Correct 109 ms 1356 KB Output is correct
37 Correct 422 ms 1480 KB Output is correct
38 Correct 361 ms 1484 KB Output is correct
39 Correct 588 ms 1356 KB Output is correct
40 Correct 846 ms 1476 KB Output is correct
41 Correct 655 ms 1356 KB Output is correct
42 Correct 599 ms 1484 KB Output is correct
43 Correct 627 ms 1740 KB Output is correct
44 Correct 546 ms 1644 KB Output is correct
45 Correct 544 ms 1740 KB Output is correct
46 Correct 635 ms 1356 KB Output is correct
47 Correct 532 ms 1488 KB Output is correct
48 Correct 587 ms 1612 KB Output is correct
49 Correct 512 ms 1356 KB Output is correct
50 Correct 595 ms 1484 KB Output is correct
51 Correct 1 ms 1356 KB Output is correct
52 Correct 706 ms 1744 KB Output is correct
53 Correct 849 ms 1616 KB Output is correct
54 Execution timed out 1006 ms 1736 KB Time limit exceeded
55 Halted 0 ms 0 KB -