Submission #404374

# Submission time Handle Problem Language Result Execution time Memory
404374 2021-05-14T09:41:57 Z fvogel499 Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 716 KB
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <queue>
#include <cstring>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>

using namespace std;

#define pii pair<int, int>
#define f first
#define s second

#define ll long long
#define rint int32_t

const int siz = 125001;

rint main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    int n;
    cin >> n;

    int raw [n];
    for (int i = 0; i < n; i++) cin >> raw[i];

    bitset<siz> check(0);
    check[0] = 1;
    int checkSum = 0;
    for (int i = 0; i < n; i++) {
        check |= check<<raw[i];
        checkSum += raw[i];
    }
    if (checkSum%2 == 1 or check[checkSum/2] == 0) {
        cout << 0;
        return 0;
    }

    bitset<siz> even;
    bitset<siz> uneven;
    even.set();
    uneven.set();
    even[0] = 0;
    bool evenKilled = false;
    bool unevenKilled = false;
    bitset<siz> cur;
    for (int i = 0; i < n; i++) {
        cur.reset();
        cur[0] = 1;
        int locSum = 0;
        for (int j = 0; j < n; j++) if (i != j) {
            cur |= cur<<raw[j];
            locSum += raw[j];
        }
        if (locSum%2 == 0) {
            even &= cur>>(locSum/2);
            if (!unevenKilled) {
                uneven &= 0;
                unevenKilled = true;
            }
        }
        else {
            uneven &= cur>>(locSum/2+1);
            if (!evenKilled) {
                even &= 0;
                evenKilled = true;
            }
        }
    }

    cout << even.count()+uneven.count() << endl;
    for (int i = 0; i < siz; i++) {
        if (even[i]) cout << i*2 << " ";
        if (uneven[i]) cout << i*2+1 << " ";
    }

    int d = 0;
    d++;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 2 ms 404 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 2 ms 404 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 7 ms 332 KB Output is correct
11 Correct 5 ms 332 KB Output is correct
12 Correct 5 ms 332 KB Output is correct
13 Correct 4 ms 332 KB Output is correct
14 Correct 5 ms 392 KB Output is correct
15 Correct 5 ms 396 KB Output is correct
16 Correct 5 ms 332 KB Output is correct
17 Correct 3 ms 400 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 4 ms 332 KB Output is correct
20 Correct 5 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 2 ms 404 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 7 ms 332 KB Output is correct
11 Correct 5 ms 332 KB Output is correct
12 Correct 5 ms 332 KB Output is correct
13 Correct 4 ms 332 KB Output is correct
14 Correct 5 ms 392 KB Output is correct
15 Correct 5 ms 396 KB Output is correct
16 Correct 5 ms 332 KB Output is correct
17 Correct 3 ms 400 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 4 ms 332 KB Output is correct
20 Correct 5 ms 332 KB Output is correct
21 Correct 18 ms 392 KB Output is correct
22 Correct 26 ms 332 KB Output is correct
23 Correct 12 ms 332 KB Output is correct
24 Correct 37 ms 388 KB Output is correct
25 Correct 38 ms 388 KB Output is correct
26 Correct 46 ms 380 KB Output is correct
27 Correct 55 ms 380 KB Output is correct
28 Correct 43 ms 376 KB Output is correct
29 Correct 43 ms 388 KB Output is correct
30 Correct 42 ms 332 KB Output is correct
31 Correct 55 ms 388 KB Output is correct
32 Correct 43 ms 376 KB Output is correct
33 Correct 42 ms 332 KB Output is correct
34 Correct 43 ms 332 KB Output is correct
35 Correct 42 ms 376 KB Output is correct
36 Correct 43 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 2 ms 404 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 7 ms 332 KB Output is correct
11 Correct 5 ms 332 KB Output is correct
12 Correct 5 ms 332 KB Output is correct
13 Correct 4 ms 332 KB Output is correct
14 Correct 5 ms 392 KB Output is correct
15 Correct 5 ms 396 KB Output is correct
16 Correct 5 ms 332 KB Output is correct
17 Correct 3 ms 400 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 4 ms 332 KB Output is correct
20 Correct 5 ms 332 KB Output is correct
21 Correct 18 ms 392 KB Output is correct
22 Correct 26 ms 332 KB Output is correct
23 Correct 12 ms 332 KB Output is correct
24 Correct 37 ms 388 KB Output is correct
25 Correct 38 ms 388 KB Output is correct
26 Correct 46 ms 380 KB Output is correct
27 Correct 55 ms 380 KB Output is correct
28 Correct 43 ms 376 KB Output is correct
29 Correct 43 ms 388 KB Output is correct
30 Correct 42 ms 332 KB Output is correct
31 Correct 55 ms 388 KB Output is correct
32 Correct 43 ms 376 KB Output is correct
33 Correct 42 ms 332 KB Output is correct
34 Correct 43 ms 332 KB Output is correct
35 Correct 42 ms 376 KB Output is correct
36 Correct 43 ms 376 KB Output is correct
37 Correct 172 ms 376 KB Output is correct
38 Correct 168 ms 388 KB Output is correct
39 Correct 257 ms 452 KB Output is correct
40 Correct 300 ms 380 KB Output is correct
41 Correct 323 ms 332 KB Output is correct
42 Correct 257 ms 372 KB Output is correct
43 Correct 246 ms 504 KB Output is correct
44 Correct 257 ms 500 KB Output is correct
45 Correct 292 ms 520 KB Output is correct
46 Correct 296 ms 380 KB Output is correct
47 Correct 261 ms 452 KB Output is correct
48 Correct 263 ms 372 KB Output is correct
49 Correct 262 ms 388 KB Output is correct
50 Correct 259 ms 384 KB Output is correct
51 Correct 2 ms 396 KB Output is correct
52 Correct 302 ms 516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 2 ms 404 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 7 ms 332 KB Output is correct
11 Correct 5 ms 332 KB Output is correct
12 Correct 5 ms 332 KB Output is correct
13 Correct 4 ms 332 KB Output is correct
14 Correct 5 ms 392 KB Output is correct
15 Correct 5 ms 396 KB Output is correct
16 Correct 5 ms 332 KB Output is correct
17 Correct 3 ms 400 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 4 ms 332 KB Output is correct
20 Correct 5 ms 332 KB Output is correct
21 Correct 18 ms 392 KB Output is correct
22 Correct 26 ms 332 KB Output is correct
23 Correct 12 ms 332 KB Output is correct
24 Correct 37 ms 388 KB Output is correct
25 Correct 38 ms 388 KB Output is correct
26 Correct 46 ms 380 KB Output is correct
27 Correct 55 ms 380 KB Output is correct
28 Correct 43 ms 376 KB Output is correct
29 Correct 43 ms 388 KB Output is correct
30 Correct 42 ms 332 KB Output is correct
31 Correct 55 ms 388 KB Output is correct
32 Correct 43 ms 376 KB Output is correct
33 Correct 42 ms 332 KB Output is correct
34 Correct 43 ms 332 KB Output is correct
35 Correct 42 ms 376 KB Output is correct
36 Correct 43 ms 376 KB Output is correct
37 Correct 172 ms 376 KB Output is correct
38 Correct 168 ms 388 KB Output is correct
39 Correct 257 ms 452 KB Output is correct
40 Correct 300 ms 380 KB Output is correct
41 Correct 323 ms 332 KB Output is correct
42 Correct 257 ms 372 KB Output is correct
43 Correct 246 ms 504 KB Output is correct
44 Correct 257 ms 500 KB Output is correct
45 Correct 292 ms 520 KB Output is correct
46 Correct 296 ms 380 KB Output is correct
47 Correct 261 ms 452 KB Output is correct
48 Correct 263 ms 372 KB Output is correct
49 Correct 262 ms 388 KB Output is correct
50 Correct 259 ms 384 KB Output is correct
51 Correct 2 ms 396 KB Output is correct
52 Correct 302 ms 516 KB Output is correct
53 Correct 378 ms 504 KB Output is correct
54 Correct 503 ms 504 KB Output is correct
55 Correct 564 ms 632 KB Output is correct
56 Correct 389 ms 504 KB Output is correct
57 Correct 510 ms 632 KB Output is correct
58 Correct 502 ms 580 KB Output is correct
59 Correct 532 ms 504 KB Output is correct
60 Correct 2 ms 332 KB Output is correct
61 Correct 508 ms 520 KB Output is correct
62 Correct 430 ms 628 KB Output is correct
63 Correct 430 ms 644 KB Output is correct
64 Correct 413 ms 716 KB Output is correct
65 Correct 419 ms 376 KB Output is correct
66 Correct 400 ms 372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 2 ms 404 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 7 ms 332 KB Output is correct
11 Correct 5 ms 332 KB Output is correct
12 Correct 5 ms 332 KB Output is correct
13 Correct 4 ms 332 KB Output is correct
14 Correct 5 ms 392 KB Output is correct
15 Correct 5 ms 396 KB Output is correct
16 Correct 5 ms 332 KB Output is correct
17 Correct 3 ms 400 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 4 ms 332 KB Output is correct
20 Correct 5 ms 332 KB Output is correct
21 Correct 18 ms 392 KB Output is correct
22 Correct 26 ms 332 KB Output is correct
23 Correct 12 ms 332 KB Output is correct
24 Correct 37 ms 388 KB Output is correct
25 Correct 38 ms 388 KB Output is correct
26 Correct 46 ms 380 KB Output is correct
27 Correct 55 ms 380 KB Output is correct
28 Correct 43 ms 376 KB Output is correct
29 Correct 43 ms 388 KB Output is correct
30 Correct 42 ms 332 KB Output is correct
31 Correct 55 ms 388 KB Output is correct
32 Correct 43 ms 376 KB Output is correct
33 Correct 42 ms 332 KB Output is correct
34 Correct 43 ms 332 KB Output is correct
35 Correct 42 ms 376 KB Output is correct
36 Correct 43 ms 376 KB Output is correct
37 Correct 172 ms 376 KB Output is correct
38 Correct 168 ms 388 KB Output is correct
39 Correct 257 ms 452 KB Output is correct
40 Correct 300 ms 380 KB Output is correct
41 Correct 323 ms 332 KB Output is correct
42 Correct 257 ms 372 KB Output is correct
43 Correct 246 ms 504 KB Output is correct
44 Correct 257 ms 500 KB Output is correct
45 Correct 292 ms 520 KB Output is correct
46 Correct 296 ms 380 KB Output is correct
47 Correct 261 ms 452 KB Output is correct
48 Correct 263 ms 372 KB Output is correct
49 Correct 262 ms 388 KB Output is correct
50 Correct 259 ms 384 KB Output is correct
51 Correct 2 ms 396 KB Output is correct
52 Correct 302 ms 516 KB Output is correct
53 Correct 378 ms 504 KB Output is correct
54 Correct 503 ms 504 KB Output is correct
55 Correct 564 ms 632 KB Output is correct
56 Correct 389 ms 504 KB Output is correct
57 Correct 510 ms 632 KB Output is correct
58 Correct 502 ms 580 KB Output is correct
59 Correct 532 ms 504 KB Output is correct
60 Correct 2 ms 332 KB Output is correct
61 Correct 508 ms 520 KB Output is correct
62 Correct 430 ms 628 KB Output is correct
63 Correct 430 ms 644 KB Output is correct
64 Correct 413 ms 716 KB Output is correct
65 Correct 419 ms 376 KB Output is correct
66 Correct 400 ms 372 KB Output is correct
67 Correct 664 ms 508 KB Output is correct
68 Correct 3 ms 460 KB Output is correct
69 Execution timed out 1062 ms 376 KB Time limit exceeded
70 Halted 0 ms 0 KB -