Submission #211283

# Submission time Handle Problem Language Result Execution time Memory
211283 2020-03-20T01:30:40 Z nouvo25 Bootfall (IZhO17_bootfall) C++14
44 / 100
1000 ms 1524 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 507;

int n, a[maxn], cnt[maxn*maxn], s = 0;
bitset<maxn*maxn> f, tmp;
vector<int> ans;

int main()
{
//    freopen("test.INP","r",stdin);
    scanf("%d",&n);
    for (int i = 1; i <= n; ++i) scanf("%d",&a[i]), s += a[i];
    if (s % 2) return puts("0"), 0;

    f[0] = 1;
    for (int i = 1; i <= n; ++i)
        tmp = f, tmp <<= a[i], f |= tmp;
    if (!f[s / 2]) return puts("0"), 0;

    for (int i = 1; i <= n; ++i)
    {
        s -= a[i];
        for (int j = 1; j <= s; ++j) f[j] = 0;
        for (int j = 1; j <= n; ++j)
            if (j != i) tmp = f, tmp <<= a[j], f |= tmp;
        for (int j = 0; j <= s; ++j)
            if (f[j]) cnt[abs(s - 2*j)] += f[j];
        s += a[i];
    }

    for (int i = 0; i <= s; ++i)
        if (cnt[i] == 2*n) ans.push_back(i);
    printf("%d\n",ans.size());
    for (auto v: ans) printf("%d ",v);
    return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:36:29: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
     printf("%d\n",ans.size());
                   ~~~~~~~~~~^
bootfall.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
bootfall.cpp:15:51: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (int i = 1; i <= n; ++i) scanf("%d",&a[i]), s += a[i];
                                  ~~~~~~~~~~~~~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 432 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 432 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 12 ms 384 KB Output is correct
11 Correct 11 ms 384 KB Output is correct
12 Correct 12 ms 384 KB Output is correct
13 Correct 9 ms 384 KB Output is correct
14 Correct 10 ms 384 KB Output is correct
15 Correct 10 ms 384 KB Output is correct
16 Correct 11 ms 384 KB Output is correct
17 Correct 7 ms 384 KB Output is correct
18 Correct 9 ms 384 KB Output is correct
19 Correct 13 ms 384 KB Output is correct
20 Correct 11 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 432 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 12 ms 384 KB Output is correct
11 Correct 11 ms 384 KB Output is correct
12 Correct 12 ms 384 KB Output is correct
13 Correct 9 ms 384 KB Output is correct
14 Correct 10 ms 384 KB Output is correct
15 Correct 10 ms 384 KB Output is correct
16 Correct 11 ms 384 KB Output is correct
17 Correct 7 ms 384 KB Output is correct
18 Correct 9 ms 384 KB Output is correct
19 Correct 13 ms 384 KB Output is correct
20 Correct 11 ms 384 KB Output is correct
21 Correct 36 ms 512 KB Output is correct
22 Correct 54 ms 384 KB Output is correct
23 Correct 24 ms 384 KB Output is correct
24 Correct 72 ms 384 KB Output is correct
25 Correct 74 ms 504 KB Output is correct
26 Correct 82 ms 504 KB Output is correct
27 Correct 87 ms 384 KB Output is correct
28 Correct 81 ms 384 KB Output is correct
29 Correct 82 ms 384 KB Output is correct
30 Correct 81 ms 384 KB Output is correct
31 Correct 83 ms 504 KB Output is correct
32 Correct 80 ms 384 KB Output is correct
33 Correct 82 ms 632 KB Output is correct
34 Correct 82 ms 384 KB Output is correct
35 Correct 80 ms 384 KB Output is correct
36 Correct 80 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 432 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 12 ms 384 KB Output is correct
11 Correct 11 ms 384 KB Output is correct
12 Correct 12 ms 384 KB Output is correct
13 Correct 9 ms 384 KB Output is correct
14 Correct 10 ms 384 KB Output is correct
15 Correct 10 ms 384 KB Output is correct
16 Correct 11 ms 384 KB Output is correct
17 Correct 7 ms 384 KB Output is correct
18 Correct 9 ms 384 KB Output is correct
19 Correct 13 ms 384 KB Output is correct
20 Correct 11 ms 384 KB Output is correct
21 Correct 36 ms 512 KB Output is correct
22 Correct 54 ms 384 KB Output is correct
23 Correct 24 ms 384 KB Output is correct
24 Correct 72 ms 384 KB Output is correct
25 Correct 74 ms 504 KB Output is correct
26 Correct 82 ms 504 KB Output is correct
27 Correct 87 ms 384 KB Output is correct
28 Correct 81 ms 384 KB Output is correct
29 Correct 82 ms 384 KB Output is correct
30 Correct 81 ms 384 KB Output is correct
31 Correct 83 ms 504 KB Output is correct
32 Correct 80 ms 384 KB Output is correct
33 Correct 82 ms 632 KB Output is correct
34 Correct 82 ms 384 KB Output is correct
35 Correct 80 ms 384 KB Output is correct
36 Correct 80 ms 504 KB Output is correct
37 Correct 313 ms 640 KB Output is correct
38 Correct 321 ms 632 KB Output is correct
39 Correct 495 ms 572 KB Output is correct
40 Correct 579 ms 760 KB Output is correct
41 Correct 603 ms 640 KB Output is correct
42 Correct 525 ms 760 KB Output is correct
43 Correct 509 ms 1016 KB Output is correct
44 Correct 531 ms 1144 KB Output is correct
45 Correct 509 ms 1144 KB Output is correct
46 Correct 558 ms 504 KB Output is correct
47 Correct 509 ms 888 KB Output is correct
48 Correct 515 ms 1016 KB Output is correct
49 Correct 515 ms 640 KB Output is correct
50 Correct 507 ms 724 KB Output is correct
51 Correct 4 ms 384 KB Output is correct
52 Correct 617 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 432 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 12 ms 384 KB Output is correct
11 Correct 11 ms 384 KB Output is correct
12 Correct 12 ms 384 KB Output is correct
13 Correct 9 ms 384 KB Output is correct
14 Correct 10 ms 384 KB Output is correct
15 Correct 10 ms 384 KB Output is correct
16 Correct 11 ms 384 KB Output is correct
17 Correct 7 ms 384 KB Output is correct
18 Correct 9 ms 384 KB Output is correct
19 Correct 13 ms 384 KB Output is correct
20 Correct 11 ms 384 KB Output is correct
21 Correct 36 ms 512 KB Output is correct
22 Correct 54 ms 384 KB Output is correct
23 Correct 24 ms 384 KB Output is correct
24 Correct 72 ms 384 KB Output is correct
25 Correct 74 ms 504 KB Output is correct
26 Correct 82 ms 504 KB Output is correct
27 Correct 87 ms 384 KB Output is correct
28 Correct 81 ms 384 KB Output is correct
29 Correct 82 ms 384 KB Output is correct
30 Correct 81 ms 384 KB Output is correct
31 Correct 83 ms 504 KB Output is correct
32 Correct 80 ms 384 KB Output is correct
33 Correct 82 ms 632 KB Output is correct
34 Correct 82 ms 384 KB Output is correct
35 Correct 80 ms 384 KB Output is correct
36 Correct 80 ms 504 KB Output is correct
37 Correct 313 ms 640 KB Output is correct
38 Correct 321 ms 632 KB Output is correct
39 Correct 495 ms 572 KB Output is correct
40 Correct 579 ms 760 KB Output is correct
41 Correct 603 ms 640 KB Output is correct
42 Correct 525 ms 760 KB Output is correct
43 Correct 509 ms 1016 KB Output is correct
44 Correct 531 ms 1144 KB Output is correct
45 Correct 509 ms 1144 KB Output is correct
46 Correct 558 ms 504 KB Output is correct
47 Correct 509 ms 888 KB Output is correct
48 Correct 515 ms 1016 KB Output is correct
49 Correct 515 ms 640 KB Output is correct
50 Correct 507 ms 724 KB Output is correct
51 Correct 4 ms 384 KB Output is correct
52 Correct 617 ms 1144 KB Output is correct
53 Correct 704 ms 888 KB Output is correct
54 Correct 961 ms 1016 KB Output is correct
55 Execution timed out 1039 ms 1524 KB Time limit exceeded
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 432 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 12 ms 384 KB Output is correct
11 Correct 11 ms 384 KB Output is correct
12 Correct 12 ms 384 KB Output is correct
13 Correct 9 ms 384 KB Output is correct
14 Correct 10 ms 384 KB Output is correct
15 Correct 10 ms 384 KB Output is correct
16 Correct 11 ms 384 KB Output is correct
17 Correct 7 ms 384 KB Output is correct
18 Correct 9 ms 384 KB Output is correct
19 Correct 13 ms 384 KB Output is correct
20 Correct 11 ms 384 KB Output is correct
21 Correct 36 ms 512 KB Output is correct
22 Correct 54 ms 384 KB Output is correct
23 Correct 24 ms 384 KB Output is correct
24 Correct 72 ms 384 KB Output is correct
25 Correct 74 ms 504 KB Output is correct
26 Correct 82 ms 504 KB Output is correct
27 Correct 87 ms 384 KB Output is correct
28 Correct 81 ms 384 KB Output is correct
29 Correct 82 ms 384 KB Output is correct
30 Correct 81 ms 384 KB Output is correct
31 Correct 83 ms 504 KB Output is correct
32 Correct 80 ms 384 KB Output is correct
33 Correct 82 ms 632 KB Output is correct
34 Correct 82 ms 384 KB Output is correct
35 Correct 80 ms 384 KB Output is correct
36 Correct 80 ms 504 KB Output is correct
37 Correct 313 ms 640 KB Output is correct
38 Correct 321 ms 632 KB Output is correct
39 Correct 495 ms 572 KB Output is correct
40 Correct 579 ms 760 KB Output is correct
41 Correct 603 ms 640 KB Output is correct
42 Correct 525 ms 760 KB Output is correct
43 Correct 509 ms 1016 KB Output is correct
44 Correct 531 ms 1144 KB Output is correct
45 Correct 509 ms 1144 KB Output is correct
46 Correct 558 ms 504 KB Output is correct
47 Correct 509 ms 888 KB Output is correct
48 Correct 515 ms 1016 KB Output is correct
49 Correct 515 ms 640 KB Output is correct
50 Correct 507 ms 724 KB Output is correct
51 Correct 4 ms 384 KB Output is correct
52 Correct 617 ms 1144 KB Output is correct
53 Correct 704 ms 888 KB Output is correct
54 Correct 961 ms 1016 KB Output is correct
55 Execution timed out 1039 ms 1524 KB Time limit exceeded
56 Halted 0 ms 0 KB -