Submission #507199

# Submission time Handle Problem Language Result Execution time Memory
507199 2022-01-12T09:39:23 Z dannyboy20031204 Bootfall (IZhO17_bootfall) C++17
44 / 100
1000 ms 1740 KB
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define mp make_pair
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");
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1356 KB Output is correct
2 Correct 3 ms 1356 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 2 ms 1356 KB Output is correct
5 Correct 5 ms 1292 KB Output is correct
6 Correct 4 ms 1356 KB Output is correct
7 Correct 3 ms 1356 KB Output is correct
8 Correct 5 ms 1356 KB Output is correct
9 Correct 4 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1356 KB Output is correct
2 Correct 3 ms 1356 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 2 ms 1356 KB Output is correct
5 Correct 5 ms 1292 KB Output is correct
6 Correct 4 ms 1356 KB Output is correct
7 Correct 3 ms 1356 KB Output is correct
8 Correct 5 ms 1356 KB Output is correct
9 Correct 4 ms 1356 KB Output is correct
10 Correct 13 ms 1372 KB Output is correct
11 Correct 14 ms 1372 KB Output is correct
12 Correct 14 ms 1372 KB Output is correct
13 Correct 18 ms 1376 KB Output is correct
14 Correct 14 ms 1372 KB Output is correct
15 Correct 13 ms 1368 KB Output is correct
16 Correct 14 ms 1356 KB Output is correct
17 Correct 9 ms 1372 KB Output is correct
18 Correct 15 ms 1356 KB Output is correct
19 Correct 14 ms 1356 KB Output is correct
20 Correct 14 ms 1380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1356 KB Output is correct
2 Correct 3 ms 1356 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 2 ms 1356 KB Output is correct
5 Correct 5 ms 1292 KB Output is correct
6 Correct 4 ms 1356 KB Output is correct
7 Correct 3 ms 1356 KB Output is correct
8 Correct 5 ms 1356 KB Output is correct
9 Correct 4 ms 1356 KB Output is correct
10 Correct 13 ms 1372 KB Output is correct
11 Correct 14 ms 1372 KB Output is correct
12 Correct 14 ms 1372 KB Output is correct
13 Correct 18 ms 1376 KB Output is correct
14 Correct 14 ms 1372 KB Output is correct
15 Correct 13 ms 1368 KB Output is correct
16 Correct 14 ms 1356 KB Output is correct
17 Correct 9 ms 1372 KB Output is correct
18 Correct 15 ms 1356 KB Output is correct
19 Correct 14 ms 1356 KB Output is correct
20 Correct 14 ms 1380 KB Output is correct
21 Correct 42 ms 1364 KB Output is correct
22 Correct 73 ms 1356 KB Output is correct
23 Correct 28 ms 1380 KB Output is correct
24 Correct 85 ms 1356 KB Output is correct
25 Correct 91 ms 1356 KB Output is correct
26 Correct 93 ms 1356 KB Output is correct
27 Correct 89 ms 1356 KB Output is correct
28 Correct 89 ms 1356 KB Output is correct
29 Correct 92 ms 1356 KB Output is correct
30 Correct 99 ms 1356 KB Output is correct
31 Correct 91 ms 1368 KB Output is correct
32 Correct 89 ms 1356 KB Output is correct
33 Correct 99 ms 1356 KB Output is correct
34 Correct 122 ms 1356 KB Output is correct
35 Correct 90 ms 1356 KB Output is correct
36 Correct 118 ms 1392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1356 KB Output is correct
2 Correct 3 ms 1356 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 2 ms 1356 KB Output is correct
5 Correct 5 ms 1292 KB Output is correct
6 Correct 4 ms 1356 KB Output is correct
7 Correct 3 ms 1356 KB Output is correct
8 Correct 5 ms 1356 KB Output is correct
9 Correct 4 ms 1356 KB Output is correct
10 Correct 13 ms 1372 KB Output is correct
11 Correct 14 ms 1372 KB Output is correct
12 Correct 14 ms 1372 KB Output is correct
13 Correct 18 ms 1376 KB Output is correct
14 Correct 14 ms 1372 KB Output is correct
15 Correct 13 ms 1368 KB Output is correct
16 Correct 14 ms 1356 KB Output is correct
17 Correct 9 ms 1372 KB Output is correct
18 Correct 15 ms 1356 KB Output is correct
19 Correct 14 ms 1356 KB Output is correct
20 Correct 14 ms 1380 KB Output is correct
21 Correct 42 ms 1364 KB Output is correct
22 Correct 73 ms 1356 KB Output is correct
23 Correct 28 ms 1380 KB Output is correct
24 Correct 85 ms 1356 KB Output is correct
25 Correct 91 ms 1356 KB Output is correct
26 Correct 93 ms 1356 KB Output is correct
27 Correct 89 ms 1356 KB Output is correct
28 Correct 89 ms 1356 KB Output is correct
29 Correct 92 ms 1356 KB Output is correct
30 Correct 99 ms 1356 KB Output is correct
31 Correct 91 ms 1368 KB Output is correct
32 Correct 89 ms 1356 KB Output is correct
33 Correct 99 ms 1356 KB Output is correct
34 Correct 122 ms 1356 KB Output is correct
35 Correct 90 ms 1356 KB Output is correct
36 Correct 118 ms 1392 KB Output is correct
37 Correct 383 ms 1488 KB Output is correct
38 Correct 384 ms 1484 KB Output is correct
39 Correct 583 ms 1356 KB Output is correct
40 Correct 675 ms 1476 KB Output is correct
41 Correct 597 ms 1356 KB Output is correct
42 Correct 581 ms 1476 KB Output is correct
43 Correct 481 ms 1736 KB Output is correct
44 Correct 512 ms 1732 KB Output is correct
45 Correct 503 ms 1736 KB Output is correct
46 Correct 574 ms 1356 KB Output is correct
47 Correct 508 ms 1484 KB Output is correct
48 Correct 549 ms 1616 KB Output is correct
49 Correct 544 ms 1356 KB Output is correct
50 Correct 593 ms 1496 KB Output is correct
51 Correct 1 ms 1356 KB Output is correct
52 Correct 835 ms 1740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1356 KB Output is correct
2 Correct 3 ms 1356 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 2 ms 1356 KB Output is correct
5 Correct 5 ms 1292 KB Output is correct
6 Correct 4 ms 1356 KB Output is correct
7 Correct 3 ms 1356 KB Output is correct
8 Correct 5 ms 1356 KB Output is correct
9 Correct 4 ms 1356 KB Output is correct
10 Correct 13 ms 1372 KB Output is correct
11 Correct 14 ms 1372 KB Output is correct
12 Correct 14 ms 1372 KB Output is correct
13 Correct 18 ms 1376 KB Output is correct
14 Correct 14 ms 1372 KB Output is correct
15 Correct 13 ms 1368 KB Output is correct
16 Correct 14 ms 1356 KB Output is correct
17 Correct 9 ms 1372 KB Output is correct
18 Correct 15 ms 1356 KB Output is correct
19 Correct 14 ms 1356 KB Output is correct
20 Correct 14 ms 1380 KB Output is correct
21 Correct 42 ms 1364 KB Output is correct
22 Correct 73 ms 1356 KB Output is correct
23 Correct 28 ms 1380 KB Output is correct
24 Correct 85 ms 1356 KB Output is correct
25 Correct 91 ms 1356 KB Output is correct
26 Correct 93 ms 1356 KB Output is correct
27 Correct 89 ms 1356 KB Output is correct
28 Correct 89 ms 1356 KB Output is correct
29 Correct 92 ms 1356 KB Output is correct
30 Correct 99 ms 1356 KB Output is correct
31 Correct 91 ms 1368 KB Output is correct
32 Correct 89 ms 1356 KB Output is correct
33 Correct 99 ms 1356 KB Output is correct
34 Correct 122 ms 1356 KB Output is correct
35 Correct 90 ms 1356 KB Output is correct
36 Correct 118 ms 1392 KB Output is correct
37 Correct 383 ms 1488 KB Output is correct
38 Correct 384 ms 1484 KB Output is correct
39 Correct 583 ms 1356 KB Output is correct
40 Correct 675 ms 1476 KB Output is correct
41 Correct 597 ms 1356 KB Output is correct
42 Correct 581 ms 1476 KB Output is correct
43 Correct 481 ms 1736 KB Output is correct
44 Correct 512 ms 1732 KB Output is correct
45 Correct 503 ms 1736 KB Output is correct
46 Correct 574 ms 1356 KB Output is correct
47 Correct 508 ms 1484 KB Output is correct
48 Correct 549 ms 1616 KB Output is correct
49 Correct 544 ms 1356 KB Output is correct
50 Correct 593 ms 1496 KB Output is correct
51 Correct 1 ms 1356 KB Output is correct
52 Correct 835 ms 1740 KB Output is correct
53 Correct 978 ms 1608 KB Output is correct
54 Execution timed out 1046 ms 1740 KB Time limit exceeded
55 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1356 KB Output is correct
2 Correct 3 ms 1356 KB Output is correct
3 Correct 1 ms 1356 KB Output is correct
4 Correct 2 ms 1356 KB Output is correct
5 Correct 5 ms 1292 KB Output is correct
6 Correct 4 ms 1356 KB Output is correct
7 Correct 3 ms 1356 KB Output is correct
8 Correct 5 ms 1356 KB Output is correct
9 Correct 4 ms 1356 KB Output is correct
10 Correct 13 ms 1372 KB Output is correct
11 Correct 14 ms 1372 KB Output is correct
12 Correct 14 ms 1372 KB Output is correct
13 Correct 18 ms 1376 KB Output is correct
14 Correct 14 ms 1372 KB Output is correct
15 Correct 13 ms 1368 KB Output is correct
16 Correct 14 ms 1356 KB Output is correct
17 Correct 9 ms 1372 KB Output is correct
18 Correct 15 ms 1356 KB Output is correct
19 Correct 14 ms 1356 KB Output is correct
20 Correct 14 ms 1380 KB Output is correct
21 Correct 42 ms 1364 KB Output is correct
22 Correct 73 ms 1356 KB Output is correct
23 Correct 28 ms 1380 KB Output is correct
24 Correct 85 ms 1356 KB Output is correct
25 Correct 91 ms 1356 KB Output is correct
26 Correct 93 ms 1356 KB Output is correct
27 Correct 89 ms 1356 KB Output is correct
28 Correct 89 ms 1356 KB Output is correct
29 Correct 92 ms 1356 KB Output is correct
30 Correct 99 ms 1356 KB Output is correct
31 Correct 91 ms 1368 KB Output is correct
32 Correct 89 ms 1356 KB Output is correct
33 Correct 99 ms 1356 KB Output is correct
34 Correct 122 ms 1356 KB Output is correct
35 Correct 90 ms 1356 KB Output is correct
36 Correct 118 ms 1392 KB Output is correct
37 Correct 383 ms 1488 KB Output is correct
38 Correct 384 ms 1484 KB Output is correct
39 Correct 583 ms 1356 KB Output is correct
40 Correct 675 ms 1476 KB Output is correct
41 Correct 597 ms 1356 KB Output is correct
42 Correct 581 ms 1476 KB Output is correct
43 Correct 481 ms 1736 KB Output is correct
44 Correct 512 ms 1732 KB Output is correct
45 Correct 503 ms 1736 KB Output is correct
46 Correct 574 ms 1356 KB Output is correct
47 Correct 508 ms 1484 KB Output is correct
48 Correct 549 ms 1616 KB Output is correct
49 Correct 544 ms 1356 KB Output is correct
50 Correct 593 ms 1496 KB Output is correct
51 Correct 1 ms 1356 KB Output is correct
52 Correct 835 ms 1740 KB Output is correct
53 Correct 978 ms 1608 KB Output is correct
54 Execution timed out 1046 ms 1740 KB Time limit exceeded
55 Halted 0 ms 0 KB -