답안 #439256

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
439256 2021-06-29T12:52:56 Z LastRonin Bootfall (IZhO17_bootfall) C++14
0 / 100
1 ms 332 KB
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0) 
#define sz(a) (a).size()
#define triple pair<pill, ll>
#define pinode pair<node*, node*>
#define quadra pair<pill, pill>
#define ld long double
using namespace std;
 
const ll N = 350 + 1;
const ll M = 1e4 + 10;
const ll big = 1e17;
const ll hsh2 = 1964325029;
const long long mod = 1e9 + 7;
const long double EPS = 1e-10;
const ll block = 1e7;
const ll shift = 2e3;
const ld pi = acos(-1.0);

ll sum = 0;
ll n;
ll a[N];
ll dp[N * N];

void add(ll x) {
	for(int i = sum + x; i >= x; i--)
		dp[i] += dp[i - x];
	sum += x;
}

void del(ll x) {
	for(int i = 0; i <= sum - x; i++) 
		dp[i + x] -= dp[i];
	sum -= x;	
}
bitset<N * N> x, ans, tr;

int main() {
	speed;
	cin >> n;
	dp[0] = 1ll;
	for(int i = 1; i <= n; i++)
		cin >> a[i], add(a[i]);
	for(int i = 1; i <= sum; i++)
		ans[i] = 1;
	if(sum % 2 != 0 && !dp[sum/2])
		cout << 0, ex;
	for(int i = 1; i <= n; i++) {
		tr = 0;
		ll sum2 = sum - a[i];
		del(a[i]);
		for(int j = 1; j <= sum2; j++) {
			if(dp[j]) {
				ll p = sum2 - j;
				ll z = j - p;
				if(z <= 0)continue;
				tr[z] = 1;	
			}
		}
		add(a[i]);
		ans &= tr;
	}
	vector<int> answ;
	for(int i = 1; i <= sum ; i++)
		if(ans[i])
			answ.pb(i);
	cout << answ.size() << '\n';
	for(auto u : answ)
		cout << u << " ";
	cout << '\n';	
				
}
/*
*/  
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -