#include <bits/stdc++.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair < int, int > pii;
typedef vector<int> vi;
typedef vector<long long> vll;
const int N = 250000 / 2 + 1;
const ll mod = 1e9 + 7;
void solve(){
int n;
cin >> n;
int a[n], x = 0;
bitset<N> can;
bool ok = 0, okk = 0;
for(int i = 0; i < n; i++) {
cin >> a[i];
if(a[i] % 2)ok = 1;
else okk = 1;
x += a[i];
}
map<int, bool> hv;
hv[0] = 1;
for(int j = 0; j < n; j++) {
vi ev;
for(auto o : hv) {
ev.pb(o.ff + a[j]);
}
for(auto o : ev)hv[o] = 1;
}
if(x % 2 || hv.find(x / 2) == hv.end() || ok & okk) {
cout << "0";
return;
}
x -= a[0];
if(x % 2)ok = 1;
else ok = 0;
for(int i = 0; i < N; i++) can[i] = 1;
for(int i = 0; i < n; i++) {
hv.clear();
x = 0;
hv[0] = 1;
for(int j = 0; j < n; j++) {
if(j == i)continue;
vi ev;
for(auto o : hv) {
ev.pb(o.ff + a[j]);
}
for(auto o : ev)hv[o] = 1;
x += a[j];
}
for(int p = can._Find_first(); p != can.size(); p = can._Find_next(p)) {
int t = p * 2 + ok;
if(hv.find((x + t) / 2) == hv.end() && hv.find((x + t) / 2 - t) == hv.end()) can[p] = 0;
}
}
cout << can.count() << '\n';
for(int p = can._Find_first(); p != can.size(); p = can._Find_next(p)) {
cout << p * 2 + ok << ' ';
}
}
int main() {
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(0);
int times = 1;
//cin >> times;
while(times--)solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
324 KB |
Output is correct |
2 |
Correct |
2 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
5 ms |
364 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
4 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
324 KB |
Output is correct |
2 |
Correct |
2 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
5 ms |
364 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
4 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
6 ms |
340 KB |
Output is correct |
12 |
Correct |
6 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
6 ms |
332 KB |
Output is correct |
15 |
Correct |
5 ms |
332 KB |
Output is correct |
16 |
Correct |
6 ms |
332 KB |
Output is correct |
17 |
Correct |
3 ms |
332 KB |
Output is correct |
18 |
Correct |
5 ms |
336 KB |
Output is correct |
19 |
Correct |
5 ms |
332 KB |
Output is correct |
20 |
Correct |
3 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
324 KB |
Output is correct |
2 |
Correct |
2 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
5 ms |
364 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
4 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
6 ms |
340 KB |
Output is correct |
12 |
Correct |
6 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
6 ms |
332 KB |
Output is correct |
15 |
Correct |
5 ms |
332 KB |
Output is correct |
16 |
Correct |
6 ms |
332 KB |
Output is correct |
17 |
Correct |
3 ms |
332 KB |
Output is correct |
18 |
Correct |
5 ms |
336 KB |
Output is correct |
19 |
Correct |
5 ms |
332 KB |
Output is correct |
20 |
Correct |
3 ms |
204 KB |
Output is correct |
21 |
Correct |
319 ms |
504 KB |
Output is correct |
22 |
Correct |
509 ms |
580 KB |
Output is correct |
23 |
Correct |
145 ms |
460 KB |
Output is correct |
24 |
Correct |
951 ms |
720 KB |
Output is correct |
25 |
Execution timed out |
1083 ms |
704 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
324 KB |
Output is correct |
2 |
Correct |
2 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
5 ms |
364 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
4 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
6 ms |
340 KB |
Output is correct |
12 |
Correct |
6 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
6 ms |
332 KB |
Output is correct |
15 |
Correct |
5 ms |
332 KB |
Output is correct |
16 |
Correct |
6 ms |
332 KB |
Output is correct |
17 |
Correct |
3 ms |
332 KB |
Output is correct |
18 |
Correct |
5 ms |
336 KB |
Output is correct |
19 |
Correct |
5 ms |
332 KB |
Output is correct |
20 |
Correct |
3 ms |
204 KB |
Output is correct |
21 |
Correct |
319 ms |
504 KB |
Output is correct |
22 |
Correct |
509 ms |
580 KB |
Output is correct |
23 |
Correct |
145 ms |
460 KB |
Output is correct |
24 |
Correct |
951 ms |
720 KB |
Output is correct |
25 |
Execution timed out |
1083 ms |
704 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
324 KB |
Output is correct |
2 |
Correct |
2 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
5 ms |
364 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
4 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
6 ms |
340 KB |
Output is correct |
12 |
Correct |
6 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
6 ms |
332 KB |
Output is correct |
15 |
Correct |
5 ms |
332 KB |
Output is correct |
16 |
Correct |
6 ms |
332 KB |
Output is correct |
17 |
Correct |
3 ms |
332 KB |
Output is correct |
18 |
Correct |
5 ms |
336 KB |
Output is correct |
19 |
Correct |
5 ms |
332 KB |
Output is correct |
20 |
Correct |
3 ms |
204 KB |
Output is correct |
21 |
Correct |
319 ms |
504 KB |
Output is correct |
22 |
Correct |
509 ms |
580 KB |
Output is correct |
23 |
Correct |
145 ms |
460 KB |
Output is correct |
24 |
Correct |
951 ms |
720 KB |
Output is correct |
25 |
Execution timed out |
1083 ms |
704 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
324 KB |
Output is correct |
2 |
Correct |
2 ms |
320 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
5 ms |
364 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
204 KB |
Output is correct |
8 |
Correct |
4 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
204 KB |
Output is correct |
11 |
Correct |
6 ms |
340 KB |
Output is correct |
12 |
Correct |
6 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
6 ms |
332 KB |
Output is correct |
15 |
Correct |
5 ms |
332 KB |
Output is correct |
16 |
Correct |
6 ms |
332 KB |
Output is correct |
17 |
Correct |
3 ms |
332 KB |
Output is correct |
18 |
Correct |
5 ms |
336 KB |
Output is correct |
19 |
Correct |
5 ms |
332 KB |
Output is correct |
20 |
Correct |
3 ms |
204 KB |
Output is correct |
21 |
Correct |
319 ms |
504 KB |
Output is correct |
22 |
Correct |
509 ms |
580 KB |
Output is correct |
23 |
Correct |
145 ms |
460 KB |
Output is correct |
24 |
Correct |
951 ms |
720 KB |
Output is correct |
25 |
Execution timed out |
1083 ms |
704 KB |
Time limit exceeded |
26 |
Halted |
0 ms |
0 KB |
- |