답안 #879607

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
879607 2023-11-27T17:53:50 Z alex_2008 Bootfall (IZhO17_bootfall) C++14
44 / 100
1000 ms 25432 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_set>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <fstream>
#include <random>
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
const int N = 510;
const int M = 251000;
int a[N];
bitset <M> b[N];
bitset <M> ch[N];
int main() {
          ios_base::sync_with_stdio(false); cin.tie(0);
	int n, sm = 0;
	cin >> n;
	bitset <M> w;
	w[0] = 1;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] % 2 != a[1] % 2) {
			cout << "0\n";
			return 0;
		}
		w |= (w << a[i]);
		sm += a[i];
	}
	if (sm % 2 == 1) {
		cout << "0\n";
		return 0;
	}
	if (!w[sm / 2]) {
		cout << "0\n";
		return 0;
	}
	for (int i = 1; i <= n; i++) {
		b[i][0] = 1;
		for (int j = 1; j <= n; j++) {
			if (i == j) continue;
			b[i] |= (b[i] << a[j]);
		}
	}
	for (int i = 1; i <= n; i++) {
		sm -= a[i];
		for (int j = 0; j <= 250000; j++) {
			if (b[i][j]) {
				if (2 * j < sm) {
					ch[i][sm - 2 * j] = 1;
				}
				else {
					ch[i][2 * j - sm] = 1;
				}
			}
		}
		sm += a[i];
	}
	vector <int> ans;
	for (int j = 1; j <= 250000; j++) {
		bool flag = true;
		for (int i = 1; i <= n; i++) {
			if (ch[i][j]) continue;
			flag = false; break;
		}
		if (flag) ans.push_back(j);
	}
	cout << (int)ans.size() << "\n";
	for (auto it : ans) {
		cout << it << " ";
	}
	cout << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 4 ms 4444 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
5 Correct 4 ms 4676 KB Output is correct
6 Correct 4 ms 4444 KB Output is correct
7 Correct 4 ms 4444 KB Output is correct
8 Correct 4 ms 4444 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 4 ms 4444 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
5 Correct 4 ms 4676 KB Output is correct
6 Correct 4 ms 4444 KB Output is correct
7 Correct 4 ms 4444 KB Output is correct
8 Correct 4 ms 4444 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 12 ms 4440 KB Output is correct
11 Correct 13 ms 4696 KB Output is correct
12 Correct 12 ms 4692 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 11 ms 4444 KB Output is correct
15 Correct 12 ms 4444 KB Output is correct
16 Correct 15 ms 4444 KB Output is correct
17 Correct 10 ms 4676 KB Output is correct
18 Correct 10 ms 4444 KB Output is correct
19 Correct 10 ms 4444 KB Output is correct
20 Correct 12 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 4 ms 4444 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
5 Correct 4 ms 4676 KB Output is correct
6 Correct 4 ms 4444 KB Output is correct
7 Correct 4 ms 4444 KB Output is correct
8 Correct 4 ms 4444 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 12 ms 4440 KB Output is correct
11 Correct 13 ms 4696 KB Output is correct
12 Correct 12 ms 4692 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 11 ms 4444 KB Output is correct
15 Correct 12 ms 4444 KB Output is correct
16 Correct 15 ms 4444 KB Output is correct
17 Correct 10 ms 4676 KB Output is correct
18 Correct 10 ms 4444 KB Output is correct
19 Correct 10 ms 4444 KB Output is correct
20 Correct 12 ms 4700 KB Output is correct
21 Correct 41 ms 5692 KB Output is correct
22 Correct 50 ms 8084 KB Output is correct
23 Correct 28 ms 5280 KB Output is correct
24 Correct 77 ms 8528 KB Output is correct
25 Correct 78 ms 8528 KB Output is correct
26 Correct 85 ms 8792 KB Output is correct
27 Correct 84 ms 8836 KB Output is correct
28 Correct 85 ms 8744 KB Output is correct
29 Correct 84 ms 8784 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 85 ms 8724 KB Output is correct
32 Correct 85 ms 8784 KB Output is correct
33 Correct 84 ms 8796 KB Output is correct
34 Correct 85 ms 8820 KB Output is correct
35 Correct 84 ms 8784 KB Output is correct
36 Correct 87 ms 8792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 4 ms 4444 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
5 Correct 4 ms 4676 KB Output is correct
6 Correct 4 ms 4444 KB Output is correct
7 Correct 4 ms 4444 KB Output is correct
8 Correct 4 ms 4444 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 12 ms 4440 KB Output is correct
11 Correct 13 ms 4696 KB Output is correct
12 Correct 12 ms 4692 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 11 ms 4444 KB Output is correct
15 Correct 12 ms 4444 KB Output is correct
16 Correct 15 ms 4444 KB Output is correct
17 Correct 10 ms 4676 KB Output is correct
18 Correct 10 ms 4444 KB Output is correct
19 Correct 10 ms 4444 KB Output is correct
20 Correct 12 ms 4700 KB Output is correct
21 Correct 41 ms 5692 KB Output is correct
22 Correct 50 ms 8084 KB Output is correct
23 Correct 28 ms 5280 KB Output is correct
24 Correct 77 ms 8528 KB Output is correct
25 Correct 78 ms 8528 KB Output is correct
26 Correct 85 ms 8792 KB Output is correct
27 Correct 84 ms 8836 KB Output is correct
28 Correct 85 ms 8744 KB Output is correct
29 Correct 84 ms 8784 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 85 ms 8724 KB Output is correct
32 Correct 85 ms 8784 KB Output is correct
33 Correct 84 ms 8796 KB Output is correct
34 Correct 85 ms 8820 KB Output is correct
35 Correct 84 ms 8784 KB Output is correct
36 Correct 87 ms 8792 KB Output is correct
37 Correct 306 ms 13992 KB Output is correct
38 Correct 309 ms 14116 KB Output is correct
39 Correct 456 ms 17448 KB Output is correct
40 Correct 580 ms 18260 KB Output is correct
41 Correct 528 ms 18028 KB Output is correct
42 Correct 471 ms 17588 KB Output is correct
43 Correct 453 ms 17748 KB Output is correct
44 Correct 484 ms 17836 KB Output is correct
45 Correct 477 ms 18000 KB Output is correct
46 Correct 526 ms 18100 KB Output is correct
47 Correct 472 ms 18000 KB Output is correct
48 Correct 475 ms 17748 KB Output is correct
49 Correct 469 ms 17696 KB Output is correct
50 Correct 470 ms 17764 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 551 ms 18492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 4 ms 4444 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
5 Correct 4 ms 4676 KB Output is correct
6 Correct 4 ms 4444 KB Output is correct
7 Correct 4 ms 4444 KB Output is correct
8 Correct 4 ms 4444 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 12 ms 4440 KB Output is correct
11 Correct 13 ms 4696 KB Output is correct
12 Correct 12 ms 4692 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 11 ms 4444 KB Output is correct
15 Correct 12 ms 4444 KB Output is correct
16 Correct 15 ms 4444 KB Output is correct
17 Correct 10 ms 4676 KB Output is correct
18 Correct 10 ms 4444 KB Output is correct
19 Correct 10 ms 4444 KB Output is correct
20 Correct 12 ms 4700 KB Output is correct
21 Correct 41 ms 5692 KB Output is correct
22 Correct 50 ms 8084 KB Output is correct
23 Correct 28 ms 5280 KB Output is correct
24 Correct 77 ms 8528 KB Output is correct
25 Correct 78 ms 8528 KB Output is correct
26 Correct 85 ms 8792 KB Output is correct
27 Correct 84 ms 8836 KB Output is correct
28 Correct 85 ms 8744 KB Output is correct
29 Correct 84 ms 8784 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 85 ms 8724 KB Output is correct
32 Correct 85 ms 8784 KB Output is correct
33 Correct 84 ms 8796 KB Output is correct
34 Correct 85 ms 8820 KB Output is correct
35 Correct 84 ms 8784 KB Output is correct
36 Correct 87 ms 8792 KB Output is correct
37 Correct 306 ms 13992 KB Output is correct
38 Correct 309 ms 14116 KB Output is correct
39 Correct 456 ms 17448 KB Output is correct
40 Correct 580 ms 18260 KB Output is correct
41 Correct 528 ms 18028 KB Output is correct
42 Correct 471 ms 17588 KB Output is correct
43 Correct 453 ms 17748 KB Output is correct
44 Correct 484 ms 17836 KB Output is correct
45 Correct 477 ms 18000 KB Output is correct
46 Correct 526 ms 18100 KB Output is correct
47 Correct 472 ms 18000 KB Output is correct
48 Correct 475 ms 17748 KB Output is correct
49 Correct 469 ms 17696 KB Output is correct
50 Correct 470 ms 17764 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 551 ms 18492 KB Output is correct
53 Correct 684 ms 21440 KB Output is correct
54 Correct 932 ms 25136 KB Output is correct
55 Correct 970 ms 25432 KB Output is correct
56 Correct 722 ms 21716 KB Output is correct
57 Correct 963 ms 25260 KB Output is correct
58 Correct 916 ms 25128 KB Output is correct
59 Correct 914 ms 25248 KB Output is correct
60 Correct 1 ms 344 KB Output is correct
61 Correct 926 ms 25256 KB Output is correct
62 Correct 773 ms 22232 KB Output is correct
63 Execution timed out 1029 ms 22220 KB Time limit exceeded
64 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2396 KB Output is correct
2 Correct 4 ms 4444 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 2396 KB Output is correct
5 Correct 4 ms 4676 KB Output is correct
6 Correct 4 ms 4444 KB Output is correct
7 Correct 4 ms 4444 KB Output is correct
8 Correct 4 ms 4444 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 12 ms 4440 KB Output is correct
11 Correct 13 ms 4696 KB Output is correct
12 Correct 12 ms 4692 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 11 ms 4444 KB Output is correct
15 Correct 12 ms 4444 KB Output is correct
16 Correct 15 ms 4444 KB Output is correct
17 Correct 10 ms 4676 KB Output is correct
18 Correct 10 ms 4444 KB Output is correct
19 Correct 10 ms 4444 KB Output is correct
20 Correct 12 ms 4700 KB Output is correct
21 Correct 41 ms 5692 KB Output is correct
22 Correct 50 ms 8084 KB Output is correct
23 Correct 28 ms 5280 KB Output is correct
24 Correct 77 ms 8528 KB Output is correct
25 Correct 78 ms 8528 KB Output is correct
26 Correct 85 ms 8792 KB Output is correct
27 Correct 84 ms 8836 KB Output is correct
28 Correct 85 ms 8744 KB Output is correct
29 Correct 84 ms 8784 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 85 ms 8724 KB Output is correct
32 Correct 85 ms 8784 KB Output is correct
33 Correct 84 ms 8796 KB Output is correct
34 Correct 85 ms 8820 KB Output is correct
35 Correct 84 ms 8784 KB Output is correct
36 Correct 87 ms 8792 KB Output is correct
37 Correct 306 ms 13992 KB Output is correct
38 Correct 309 ms 14116 KB Output is correct
39 Correct 456 ms 17448 KB Output is correct
40 Correct 580 ms 18260 KB Output is correct
41 Correct 528 ms 18028 KB Output is correct
42 Correct 471 ms 17588 KB Output is correct
43 Correct 453 ms 17748 KB Output is correct
44 Correct 484 ms 17836 KB Output is correct
45 Correct 477 ms 18000 KB Output is correct
46 Correct 526 ms 18100 KB Output is correct
47 Correct 472 ms 18000 KB Output is correct
48 Correct 475 ms 17748 KB Output is correct
49 Correct 469 ms 17696 KB Output is correct
50 Correct 470 ms 17764 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 551 ms 18492 KB Output is correct
53 Correct 684 ms 21440 KB Output is correct
54 Correct 932 ms 25136 KB Output is correct
55 Correct 970 ms 25432 KB Output is correct
56 Correct 722 ms 21716 KB Output is correct
57 Correct 963 ms 25260 KB Output is correct
58 Correct 916 ms 25128 KB Output is correct
59 Correct 914 ms 25248 KB Output is correct
60 Correct 1 ms 344 KB Output is correct
61 Correct 926 ms 25256 KB Output is correct
62 Correct 773 ms 22232 KB Output is correct
63 Execution timed out 1029 ms 22220 KB Time limit exceeded
64 Halted 0 ms 0 KB -