//stupid solution 1
#include <bits/stdc++.h>
#pragma GCC optimize("-Ofast")
//#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define loop(_) for (int __ = 0; __ < (_); ++__)
#define forn(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using ld = long double;
const int N = 500 + 7;
const int NN = N * N;
const ll mod = 1e9 + 7;
const ll inf = 2e18;
auto ra = [] {char *p = new char ; delete p ; return ll(p) ; };
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() * (ra() | 1));
int n;
bitset<NN> eval(vi v)
{
bitset<NN> ret;
ret[0] = 1;
for (auto u : v)
ret = (ret | (ret << u));
return ret;
}
int ret[NN];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
//freopen("in.in", "r", stdin);
cin >> n;
vi a(n), ans;
int sum = 0;
for (auto &u : a)
cin >> u;
sum = accumulate(a.begin(), a.end(), 0);
bitset<NN> bs = eval(a);
if (sum & 1 || !bs[sum / 2])
return cout << 0, 0;
set<int> st;
for (int i = 0; i < n; ++i)
{
int x = a[i];
a[i] = 0;
bitset<NN> bts = eval(a);
int sm = sum - x;
for (int j = 0; j <= sm; ++j)
{
if (bts[j])
{
if (2 * j != sm)
ret[abs(j - (sm - j))]++;
}
}
a[i] = x;
}
int sz = 0;
for (int u = 1; u < NN; ++u)
{
if (ret[u] == 2 * n)
ans.push_back(u);
}
cout << (int)ans.size() << "\n";
for (auto u : ans)
cout << u << " ";
return 0;
}
Compilation message
bootfall.cpp: In function 'int main()':
bootfall.cpp:78:13: warning: unused variable 'sz' [-Wunused-variable]
78 | int sz = 0;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
2 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
3 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
2 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
3 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
492 KB |
Output is correct |
10 |
Correct |
10 ms |
492 KB |
Output is correct |
11 |
Correct |
10 ms |
492 KB |
Output is correct |
12 |
Correct |
10 ms |
492 KB |
Output is correct |
13 |
Correct |
8 ms |
492 KB |
Output is correct |
14 |
Correct |
9 ms |
492 KB |
Output is correct |
15 |
Correct |
9 ms |
492 KB |
Output is correct |
16 |
Correct |
10 ms |
492 KB |
Output is correct |
17 |
Correct |
4 ms |
492 KB |
Output is correct |
18 |
Correct |
7 ms |
492 KB |
Output is correct |
19 |
Correct |
8 ms |
492 KB |
Output is correct |
20 |
Correct |
10 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
2 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
3 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
492 KB |
Output is correct |
10 |
Correct |
10 ms |
492 KB |
Output is correct |
11 |
Correct |
10 ms |
492 KB |
Output is correct |
12 |
Correct |
10 ms |
492 KB |
Output is correct |
13 |
Correct |
8 ms |
492 KB |
Output is correct |
14 |
Correct |
9 ms |
492 KB |
Output is correct |
15 |
Correct |
9 ms |
492 KB |
Output is correct |
16 |
Correct |
10 ms |
492 KB |
Output is correct |
17 |
Correct |
4 ms |
492 KB |
Output is correct |
18 |
Correct |
7 ms |
492 KB |
Output is correct |
19 |
Correct |
8 ms |
492 KB |
Output is correct |
20 |
Correct |
10 ms |
492 KB |
Output is correct |
21 |
Correct |
49 ms |
492 KB |
Output is correct |
22 |
Correct |
58 ms |
492 KB |
Output is correct |
23 |
Correct |
28 ms |
620 KB |
Output is correct |
24 |
Correct |
91 ms |
492 KB |
Output is correct |
25 |
Correct |
102 ms |
492 KB |
Output is correct |
26 |
Correct |
104 ms |
620 KB |
Output is correct |
27 |
Correct |
103 ms |
492 KB |
Output is correct |
28 |
Correct |
105 ms |
620 KB |
Output is correct |
29 |
Correct |
102 ms |
492 KB |
Output is correct |
30 |
Correct |
104 ms |
492 KB |
Output is correct |
31 |
Correct |
102 ms |
496 KB |
Output is correct |
32 |
Correct |
106 ms |
620 KB |
Output is correct |
33 |
Correct |
101 ms |
492 KB |
Output is correct |
34 |
Correct |
102 ms |
492 KB |
Output is correct |
35 |
Correct |
103 ms |
492 KB |
Output is correct |
36 |
Correct |
103 ms |
492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
2 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
3 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
492 KB |
Output is correct |
10 |
Correct |
10 ms |
492 KB |
Output is correct |
11 |
Correct |
10 ms |
492 KB |
Output is correct |
12 |
Correct |
10 ms |
492 KB |
Output is correct |
13 |
Correct |
8 ms |
492 KB |
Output is correct |
14 |
Correct |
9 ms |
492 KB |
Output is correct |
15 |
Correct |
9 ms |
492 KB |
Output is correct |
16 |
Correct |
10 ms |
492 KB |
Output is correct |
17 |
Correct |
4 ms |
492 KB |
Output is correct |
18 |
Correct |
7 ms |
492 KB |
Output is correct |
19 |
Correct |
8 ms |
492 KB |
Output is correct |
20 |
Correct |
10 ms |
492 KB |
Output is correct |
21 |
Correct |
49 ms |
492 KB |
Output is correct |
22 |
Correct |
58 ms |
492 KB |
Output is correct |
23 |
Correct |
28 ms |
620 KB |
Output is correct |
24 |
Correct |
91 ms |
492 KB |
Output is correct |
25 |
Correct |
102 ms |
492 KB |
Output is correct |
26 |
Correct |
104 ms |
620 KB |
Output is correct |
27 |
Correct |
103 ms |
492 KB |
Output is correct |
28 |
Correct |
105 ms |
620 KB |
Output is correct |
29 |
Correct |
102 ms |
492 KB |
Output is correct |
30 |
Correct |
104 ms |
492 KB |
Output is correct |
31 |
Correct |
102 ms |
496 KB |
Output is correct |
32 |
Correct |
106 ms |
620 KB |
Output is correct |
33 |
Correct |
101 ms |
492 KB |
Output is correct |
34 |
Correct |
102 ms |
492 KB |
Output is correct |
35 |
Correct |
103 ms |
492 KB |
Output is correct |
36 |
Correct |
103 ms |
492 KB |
Output is correct |
37 |
Correct |
408 ms |
748 KB |
Output is correct |
38 |
Correct |
414 ms |
748 KB |
Output is correct |
39 |
Correct |
625 ms |
876 KB |
Output is correct |
40 |
Correct |
750 ms |
876 KB |
Output is correct |
41 |
Correct |
739 ms |
876 KB |
Output is correct |
42 |
Correct |
646 ms |
748 KB |
Output is correct |
43 |
Correct |
625 ms |
1120 KB |
Output is correct |
44 |
Correct |
648 ms |
1132 KB |
Output is correct |
45 |
Correct |
655 ms |
1132 KB |
Output is correct |
46 |
Correct |
738 ms |
652 KB |
Output is correct |
47 |
Correct |
663 ms |
876 KB |
Output is correct |
48 |
Correct |
653 ms |
1132 KB |
Output is correct |
49 |
Correct |
649 ms |
876 KB |
Output is correct |
50 |
Correct |
650 ms |
876 KB |
Output is correct |
51 |
Correct |
3 ms |
492 KB |
Output is correct |
52 |
Correct |
756 ms |
1184 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
2 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
3 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
492 KB |
Output is correct |
10 |
Correct |
10 ms |
492 KB |
Output is correct |
11 |
Correct |
10 ms |
492 KB |
Output is correct |
12 |
Correct |
10 ms |
492 KB |
Output is correct |
13 |
Correct |
8 ms |
492 KB |
Output is correct |
14 |
Correct |
9 ms |
492 KB |
Output is correct |
15 |
Correct |
9 ms |
492 KB |
Output is correct |
16 |
Correct |
10 ms |
492 KB |
Output is correct |
17 |
Correct |
4 ms |
492 KB |
Output is correct |
18 |
Correct |
7 ms |
492 KB |
Output is correct |
19 |
Correct |
8 ms |
492 KB |
Output is correct |
20 |
Correct |
10 ms |
492 KB |
Output is correct |
21 |
Correct |
49 ms |
492 KB |
Output is correct |
22 |
Correct |
58 ms |
492 KB |
Output is correct |
23 |
Correct |
28 ms |
620 KB |
Output is correct |
24 |
Correct |
91 ms |
492 KB |
Output is correct |
25 |
Correct |
102 ms |
492 KB |
Output is correct |
26 |
Correct |
104 ms |
620 KB |
Output is correct |
27 |
Correct |
103 ms |
492 KB |
Output is correct |
28 |
Correct |
105 ms |
620 KB |
Output is correct |
29 |
Correct |
102 ms |
492 KB |
Output is correct |
30 |
Correct |
104 ms |
492 KB |
Output is correct |
31 |
Correct |
102 ms |
496 KB |
Output is correct |
32 |
Correct |
106 ms |
620 KB |
Output is correct |
33 |
Correct |
101 ms |
492 KB |
Output is correct |
34 |
Correct |
102 ms |
492 KB |
Output is correct |
35 |
Correct |
103 ms |
492 KB |
Output is correct |
36 |
Correct |
103 ms |
492 KB |
Output is correct |
37 |
Correct |
408 ms |
748 KB |
Output is correct |
38 |
Correct |
414 ms |
748 KB |
Output is correct |
39 |
Correct |
625 ms |
876 KB |
Output is correct |
40 |
Correct |
750 ms |
876 KB |
Output is correct |
41 |
Correct |
739 ms |
876 KB |
Output is correct |
42 |
Correct |
646 ms |
748 KB |
Output is correct |
43 |
Correct |
625 ms |
1120 KB |
Output is correct |
44 |
Correct |
648 ms |
1132 KB |
Output is correct |
45 |
Correct |
655 ms |
1132 KB |
Output is correct |
46 |
Correct |
738 ms |
652 KB |
Output is correct |
47 |
Correct |
663 ms |
876 KB |
Output is correct |
48 |
Correct |
653 ms |
1132 KB |
Output is correct |
49 |
Correct |
649 ms |
876 KB |
Output is correct |
50 |
Correct |
650 ms |
876 KB |
Output is correct |
51 |
Correct |
3 ms |
492 KB |
Output is correct |
52 |
Correct |
756 ms |
1184 KB |
Output is correct |
53 |
Correct |
946 ms |
960 KB |
Output is correct |
54 |
Execution timed out |
1099 ms |
620 KB |
Time limit exceeded |
55 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
492 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
2 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
3 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
492 KB |
Output is correct |
10 |
Correct |
10 ms |
492 KB |
Output is correct |
11 |
Correct |
10 ms |
492 KB |
Output is correct |
12 |
Correct |
10 ms |
492 KB |
Output is correct |
13 |
Correct |
8 ms |
492 KB |
Output is correct |
14 |
Correct |
9 ms |
492 KB |
Output is correct |
15 |
Correct |
9 ms |
492 KB |
Output is correct |
16 |
Correct |
10 ms |
492 KB |
Output is correct |
17 |
Correct |
4 ms |
492 KB |
Output is correct |
18 |
Correct |
7 ms |
492 KB |
Output is correct |
19 |
Correct |
8 ms |
492 KB |
Output is correct |
20 |
Correct |
10 ms |
492 KB |
Output is correct |
21 |
Correct |
49 ms |
492 KB |
Output is correct |
22 |
Correct |
58 ms |
492 KB |
Output is correct |
23 |
Correct |
28 ms |
620 KB |
Output is correct |
24 |
Correct |
91 ms |
492 KB |
Output is correct |
25 |
Correct |
102 ms |
492 KB |
Output is correct |
26 |
Correct |
104 ms |
620 KB |
Output is correct |
27 |
Correct |
103 ms |
492 KB |
Output is correct |
28 |
Correct |
105 ms |
620 KB |
Output is correct |
29 |
Correct |
102 ms |
492 KB |
Output is correct |
30 |
Correct |
104 ms |
492 KB |
Output is correct |
31 |
Correct |
102 ms |
496 KB |
Output is correct |
32 |
Correct |
106 ms |
620 KB |
Output is correct |
33 |
Correct |
101 ms |
492 KB |
Output is correct |
34 |
Correct |
102 ms |
492 KB |
Output is correct |
35 |
Correct |
103 ms |
492 KB |
Output is correct |
36 |
Correct |
103 ms |
492 KB |
Output is correct |
37 |
Correct |
408 ms |
748 KB |
Output is correct |
38 |
Correct |
414 ms |
748 KB |
Output is correct |
39 |
Correct |
625 ms |
876 KB |
Output is correct |
40 |
Correct |
750 ms |
876 KB |
Output is correct |
41 |
Correct |
739 ms |
876 KB |
Output is correct |
42 |
Correct |
646 ms |
748 KB |
Output is correct |
43 |
Correct |
625 ms |
1120 KB |
Output is correct |
44 |
Correct |
648 ms |
1132 KB |
Output is correct |
45 |
Correct |
655 ms |
1132 KB |
Output is correct |
46 |
Correct |
738 ms |
652 KB |
Output is correct |
47 |
Correct |
663 ms |
876 KB |
Output is correct |
48 |
Correct |
653 ms |
1132 KB |
Output is correct |
49 |
Correct |
649 ms |
876 KB |
Output is correct |
50 |
Correct |
650 ms |
876 KB |
Output is correct |
51 |
Correct |
3 ms |
492 KB |
Output is correct |
52 |
Correct |
756 ms |
1184 KB |
Output is correct |
53 |
Correct |
946 ms |
960 KB |
Output is correct |
54 |
Execution timed out |
1099 ms |
620 KB |
Time limit exceeded |
55 |
Halted |
0 ms |
0 KB |
- |