답안 #873273

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
873273 2023-11-14T17:46:01 Z c2zi6 Bootfall (IZhO17_bootfall) C++14
13 / 100
24 ms 604 KB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}

const int MAXN = 100;

const int MAXSUM = 500 * 500;
typedef bitset<MAXSUM+1> bit;

bit f(VI& v, int excludant = -1) {
	bit ans;
	ans[0] = 1;
	rep(i, v.size()) {
		if (i == excludant) continue;
		ans |= (ans << v[i]);
	}
	return ans;
}

void solve() {
	int n;
	cin >> n;
	VI a(n);
	int sum = 0;
	for (int& x : a) cin >> x, sum += x;

	bit pos = f(a);
	if (sum % 2 || !pos[sum/2]) cout << 0 << endl;
	else {
		bit ans = ~bit(0);
		rep(i, n) {
			bit pos = f(a, i);
			for (int x = 0; x <= 2500; x++) {
				int newsum = (sum - a[i] + x);
				if (newsum % 2 || newsum/2 < x || (!pos[newsum/2] && !pos[newsum/2 - x])) {
					ans[x] = false;
				}
			}
		}
		VI v;
		for (int i = 0; i <= 2500; i++) {
			if (ans[i]) v.pb(i);
		}
		cout << v.size() << endl;
		for (int x : v) cout << x << " ";
		cout << endl;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 6 ms 348 KB Output is correct
11 Correct 6 ms 348 KB Output is correct
12 Correct 6 ms 348 KB Output is correct
13 Correct 4 ms 348 KB Output is correct
14 Correct 5 ms 604 KB Output is correct
15 Correct 5 ms 488 KB Output is correct
16 Correct 5 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 4 ms 600 KB Output is correct
19 Correct 4 ms 344 KB Output is correct
20 Correct 5 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 6 ms 348 KB Output is correct
11 Correct 6 ms 348 KB Output is correct
12 Correct 6 ms 348 KB Output is correct
13 Correct 4 ms 348 KB Output is correct
14 Correct 5 ms 604 KB Output is correct
15 Correct 5 ms 488 KB Output is correct
16 Correct 5 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 4 ms 600 KB Output is correct
19 Correct 4 ms 344 KB Output is correct
20 Correct 5 ms 604 KB Output is correct
21 Incorrect 24 ms 592 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 6 ms 348 KB Output is correct
11 Correct 6 ms 348 KB Output is correct
12 Correct 6 ms 348 KB Output is correct
13 Correct 4 ms 348 KB Output is correct
14 Correct 5 ms 604 KB Output is correct
15 Correct 5 ms 488 KB Output is correct
16 Correct 5 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 4 ms 600 KB Output is correct
19 Correct 4 ms 344 KB Output is correct
20 Correct 5 ms 604 KB Output is correct
21 Incorrect 24 ms 592 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 6 ms 348 KB Output is correct
11 Correct 6 ms 348 KB Output is correct
12 Correct 6 ms 348 KB Output is correct
13 Correct 4 ms 348 KB Output is correct
14 Correct 5 ms 604 KB Output is correct
15 Correct 5 ms 488 KB Output is correct
16 Correct 5 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 4 ms 600 KB Output is correct
19 Correct 4 ms 344 KB Output is correct
20 Correct 5 ms 604 KB Output is correct
21 Incorrect 24 ms 592 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 6 ms 348 KB Output is correct
11 Correct 6 ms 348 KB Output is correct
12 Correct 6 ms 348 KB Output is correct
13 Correct 4 ms 348 KB Output is correct
14 Correct 5 ms 604 KB Output is correct
15 Correct 5 ms 488 KB Output is correct
16 Correct 5 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 4 ms 600 KB Output is correct
19 Correct 4 ms 344 KB Output is correct
20 Correct 5 ms 604 KB Output is correct
21 Incorrect 24 ms 592 KB Output isn't correct
22 Halted 0 ms 0 KB -