답안 #438161

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
438161 2021-06-27T17:04:14 Z lulwpop Bootfall (IZhO17_bootfall) C++14
13 / 100
1000 ms 2356 KB
#include <bits/stdc++.h>
#define all(X) X.begin(), X.end()
#define sz(x) (int)x.size()
#define fr first
#define sc second
#define endl '\n'
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
const int maxn = 1e6 + 10;
const int maxa = 1e6;
const int inf = 2e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;
const int block = 350;
 
int main () 
{
	ios_base::sync_with_stdio(0); cin.tie();
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	int n; cin >> n;
	vector <int> a (n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bitset <25100> st;
	int sum = 0;
	st[0] = 1;
	for (int i = 0; i < n; i++) {
		st |= (st << a[i]);
		sum += a[i];
	}
	if ((sum & 1)) {
		cout << 0;
		return 0;
	} else if (!st[sum >> 1]) {
		cout << 0;
		return 0;
	}
 
	vector <bitset <500*500+1>> t (n);
	for (int sk = 0; sk < n; sk++) {
		t[sk][0] = 1;
		for (int j = 0; j < n; j++) {
			if (j != sk) {
				t[sk] |= (t[sk] << a[j]);
			}
		}
	}
	vector <int> ans;
	for (int i = 1; i <= n * 500; i++) {
		sum += i;
		bool ok = true;
		for (int j = 0; j < n; j++) {
			bitset <500*500+1> tt = t[j];
			tt |= (tt << i);
			sum -= a[j];
			if ((sum & 1)) {
				ok = false;
				sum += a[j];
				break;
			} else if (!tt[sum >> 1]) {
				ok = false;
				sum += a[j];
				break;
			} else {
				sum += a[j];
			}
		}
		sum -= i;
		if (ok) ans.push_back(i);
	}
	cout << sz(ans) << endl;
	for (auto i : ans) {
		cout << i << " ";
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 580 KB Output is correct
2 Correct 36 ms 588 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 27 ms 460 KB Output is correct
5 Correct 96 ms 716 KB Output is correct
6 Correct 49 ms 588 KB Output is correct
7 Correct 36 ms 588 KB Output is correct
8 Correct 96 ms 716 KB Output is correct
9 Correct 66 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 580 KB Output is correct
2 Correct 36 ms 588 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 27 ms 460 KB Output is correct
5 Correct 96 ms 716 KB Output is correct
6 Correct 49 ms 588 KB Output is correct
7 Correct 36 ms 588 KB Output is correct
8 Correct 96 ms 716 KB Output is correct
9 Correct 66 ms 716 KB Output is correct
10 Correct 186 ms 1228 KB Output is correct
11 Correct 259 ms 1228 KB Output is correct
12 Correct 196 ms 1228 KB Output is correct
13 Correct 162 ms 1100 KB Output is correct
14 Correct 230 ms 1248 KB Output is correct
15 Correct 204 ms 1228 KB Output is correct
16 Correct 226 ms 1228 KB Output is correct
17 Correct 124 ms 844 KB Output is correct
18 Correct 177 ms 1100 KB Output is correct
19 Correct 191 ms 1100 KB Output is correct
20 Correct 190 ms 1228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 580 KB Output is correct
2 Correct 36 ms 588 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 27 ms 460 KB Output is correct
5 Correct 96 ms 716 KB Output is correct
6 Correct 49 ms 588 KB Output is correct
7 Correct 36 ms 588 KB Output is correct
8 Correct 96 ms 716 KB Output is correct
9 Correct 66 ms 716 KB Output is correct
10 Correct 186 ms 1228 KB Output is correct
11 Correct 259 ms 1228 KB Output is correct
12 Correct 196 ms 1228 KB Output is correct
13 Correct 162 ms 1100 KB Output is correct
14 Correct 230 ms 1248 KB Output is correct
15 Correct 204 ms 1228 KB Output is correct
16 Correct 226 ms 1228 KB Output is correct
17 Correct 124 ms 844 KB Output is correct
18 Correct 177 ms 1100 KB Output is correct
19 Correct 191 ms 1100 KB Output is correct
20 Correct 190 ms 1228 KB Output is correct
21 Execution timed out 1084 ms 2356 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 580 KB Output is correct
2 Correct 36 ms 588 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 27 ms 460 KB Output is correct
5 Correct 96 ms 716 KB Output is correct
6 Correct 49 ms 588 KB Output is correct
7 Correct 36 ms 588 KB Output is correct
8 Correct 96 ms 716 KB Output is correct
9 Correct 66 ms 716 KB Output is correct
10 Correct 186 ms 1228 KB Output is correct
11 Correct 259 ms 1228 KB Output is correct
12 Correct 196 ms 1228 KB Output is correct
13 Correct 162 ms 1100 KB Output is correct
14 Correct 230 ms 1248 KB Output is correct
15 Correct 204 ms 1228 KB Output is correct
16 Correct 226 ms 1228 KB Output is correct
17 Correct 124 ms 844 KB Output is correct
18 Correct 177 ms 1100 KB Output is correct
19 Correct 191 ms 1100 KB Output is correct
20 Correct 190 ms 1228 KB Output is correct
21 Execution timed out 1084 ms 2356 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 580 KB Output is correct
2 Correct 36 ms 588 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 27 ms 460 KB Output is correct
5 Correct 96 ms 716 KB Output is correct
6 Correct 49 ms 588 KB Output is correct
7 Correct 36 ms 588 KB Output is correct
8 Correct 96 ms 716 KB Output is correct
9 Correct 66 ms 716 KB Output is correct
10 Correct 186 ms 1228 KB Output is correct
11 Correct 259 ms 1228 KB Output is correct
12 Correct 196 ms 1228 KB Output is correct
13 Correct 162 ms 1100 KB Output is correct
14 Correct 230 ms 1248 KB Output is correct
15 Correct 204 ms 1228 KB Output is correct
16 Correct 226 ms 1228 KB Output is correct
17 Correct 124 ms 844 KB Output is correct
18 Correct 177 ms 1100 KB Output is correct
19 Correct 191 ms 1100 KB Output is correct
20 Correct 190 ms 1228 KB Output is correct
21 Execution timed out 1084 ms 2356 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 580 KB Output is correct
2 Correct 36 ms 588 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 27 ms 460 KB Output is correct
5 Correct 96 ms 716 KB Output is correct
6 Correct 49 ms 588 KB Output is correct
7 Correct 36 ms 588 KB Output is correct
8 Correct 96 ms 716 KB Output is correct
9 Correct 66 ms 716 KB Output is correct
10 Correct 186 ms 1228 KB Output is correct
11 Correct 259 ms 1228 KB Output is correct
12 Correct 196 ms 1228 KB Output is correct
13 Correct 162 ms 1100 KB Output is correct
14 Correct 230 ms 1248 KB Output is correct
15 Correct 204 ms 1228 KB Output is correct
16 Correct 226 ms 1228 KB Output is correct
17 Correct 124 ms 844 KB Output is correct
18 Correct 177 ms 1100 KB Output is correct
19 Correct 191 ms 1100 KB Output is correct
20 Correct 190 ms 1228 KB Output is correct
21 Execution timed out 1084 ms 2356 KB Time limit exceeded
22 Halted 0 ms 0 KB -