# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
953803 | 2024-03-26T17:12:59 Z | nguyennh | Bootfall (IZhO17_bootfall) | C++14 | 1000 ms | 464 KB |
#include<bits/stdc++.h> #define el '\n' using namespace std ; const int MN = 1e4 + 5; int n; namespace sub_trau{ // check whether existing a way to divide array into 2 parts with sum = x; void solve(){ vector<int> a(n + 5); for ( int i = 1 ; i <= n ; i++ ) cin >> a[i]; if (n & 1){ cout << 0; return; } bool odd = false , even = false; for ( int i = 1 ; i <= n ; i++ ){ odd |= (a[i] & 1); even |= (a[i] % 2 == 0); } if (odd && even){ cout << 0; return; } int sum = accumulate(a.begin() + 1 , a.begin() + n + 1 , 0); vector<int> ans , candidates; for ( int i = 1 ; i <= n ; i++ ) candidates.push_back(a[i]); for ( int val = odd ? 1 : 2 ; val <= sum ; val += 2 ){ int all = sum + val; candidates.push_back(val); bool check = true; for ( int turn = 0 ; turn < n + 1 ; turn++ ){ int need = all - candidates[turn]; if (need & 1){ check = false; break; } deque<int> cur; for ( int j = 0 ; j < candidates.size() ; j++ ){ if (j == turn) continue; cur.push_back(candidates[j]); } cur.push_front(-1); bitset<MN> bit; bit[0] = 1; for ( int i = 1 ; i <= n ; i++ ) bit |= (bit << cur[i]); if (!bit[need / 2]){ check = false; break; } } if (check) ans.push_back(val); candidates.pop_back(); } cout << ans.size() << el; for ( auto x : ans ) cout << x << " "; } } int32_t main (){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; sub_trau::solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 9 ms | 452 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 11 ms | 464 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 9 ms | 452 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 11 ms | 464 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 6 ms | 344 KB | Output is correct |
11 | Correct | 31 ms | 348 KB | Output is correct |
12 | Correct | 3 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 400 KB | Output is correct |
14 | Correct | 31 ms | 348 KB | Output is correct |
15 | Correct | 28 ms | 348 KB | Output is correct |
16 | Correct | 31 ms | 344 KB | Output is correct |
17 | Correct | 8 ms | 344 KB | Output is correct |
18 | Correct | 19 ms | 452 KB | Output is correct |
19 | Correct | 17 ms | 348 KB | Output is correct |
20 | Correct | 7 ms | 460 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 9 ms | 452 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 11 ms | 464 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 6 ms | 344 KB | Output is correct |
11 | Correct | 31 ms | 348 KB | Output is correct |
12 | Correct | 3 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 400 KB | Output is correct |
14 | Correct | 31 ms | 348 KB | Output is correct |
15 | Correct | 28 ms | 348 KB | Output is correct |
16 | Correct | 31 ms | 344 KB | Output is correct |
17 | Correct | 8 ms | 344 KB | Output is correct |
18 | Correct | 19 ms | 452 KB | Output is correct |
19 | Correct | 17 ms | 348 KB | Output is correct |
20 | Correct | 7 ms | 460 KB | Output is correct |
21 | Execution timed out | 1082 ms | 432 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 9 ms | 452 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 11 ms | 464 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 6 ms | 344 KB | Output is correct |
11 | Correct | 31 ms | 348 KB | Output is correct |
12 | Correct | 3 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 400 KB | Output is correct |
14 | Correct | 31 ms | 348 KB | Output is correct |
15 | Correct | 28 ms | 348 KB | Output is correct |
16 | Correct | 31 ms | 344 KB | Output is correct |
17 | Correct | 8 ms | 344 KB | Output is correct |
18 | Correct | 19 ms | 452 KB | Output is correct |
19 | Correct | 17 ms | 348 KB | Output is correct |
20 | Correct | 7 ms | 460 KB | Output is correct |
21 | Execution timed out | 1082 ms | 432 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 9 ms | 452 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 11 ms | 464 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 6 ms | 344 KB | Output is correct |
11 | Correct | 31 ms | 348 KB | Output is correct |
12 | Correct | 3 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 400 KB | Output is correct |
14 | Correct | 31 ms | 348 KB | Output is correct |
15 | Correct | 28 ms | 348 KB | Output is correct |
16 | Correct | 31 ms | 344 KB | Output is correct |
17 | Correct | 8 ms | 344 KB | Output is correct |
18 | Correct | 19 ms | 452 KB | Output is correct |
19 | Correct | 17 ms | 348 KB | Output is correct |
20 | Correct | 7 ms | 460 KB | Output is correct |
21 | Execution timed out | 1082 ms | 432 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 9 ms | 452 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 11 ms | 464 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 6 ms | 344 KB | Output is correct |
11 | Correct | 31 ms | 348 KB | Output is correct |
12 | Correct | 3 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 400 KB | Output is correct |
14 | Correct | 31 ms | 348 KB | Output is correct |
15 | Correct | 28 ms | 348 KB | Output is correct |
16 | Correct | 31 ms | 344 KB | Output is correct |
17 | Correct | 8 ms | 344 KB | Output is correct |
18 | Correct | 19 ms | 452 KB | Output is correct |
19 | Correct | 17 ms | 348 KB | Output is correct |
20 | Correct | 7 ms | 460 KB | Output is correct |
21 | Execution timed out | 1082 ms | 432 KB | Time limit exceeded |
22 | Halted | 0 ms | 0 KB | - |