Submission #91463

# Submission time Handle Problem Language Result Execution time Memory
91463 2018-12-27T15:38:38 Z davitmarg Bootfall (IZhO17_bootfall) C++17
Compilation error
0 ms 0 KB
/*
DEATH-MATCH
Davit-Marg
*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <ctype.h>
#include <stdlib.h>  
#include <fstream>  
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
using namespace std;

unsigned LL n,a[502],cant[502 * 502*4];
unsigned LL sum,sm;
vector<unsigned LL> ans;
unsigned unsigned LL dp[502 * 502*4];

void add(unsigned LL k) {
	for (unsigned LL i = sum; i >= k; i--) {
		dp[i] += dp[i - k];
	}
}

void rem(unsigned LL k) {
	for (unsigned LL i = k; i <= sum; i++) {
		dp[i] -= dp[i - k];
	}
}

int main()
{
	cin >> n;
	for (unsigned LL i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	dp[0] = 1;

	for (unsigned LL i = 0; i < n; i++)
		for (unsigned LL j = sum; j >= 0; j--)
			dp[j + a[i]]+=dp[j];

	if (sum % 2==1 || dp[sum / 2] == 0)
	{
		cout << 0 << endl;
		return 0;
	}
	sm = sum;
	for (unsigned LL i = 0; i < n; i++)
	{
		rem(a[i]);
		sum -= a[i];
		for (unsigned LL j = 0; j <= sm*2; j++)
			if ((sum+j) % 2==1 || dp[(sum+j) / 2] == 0)
				cant[j] = 1;
		add(a[i]);
		sum += a[i];
	}
	for (unsigned LL j = 1; j <= 2*sm; j++)
		if (!cant[j])
			ans.PB(j);
	
	cout << ans.size() << endl;
	if (ans.size() == 0)
		return 0;
	for (unsigned LL i = 0; i < ans.size(); i++)
		cout << ans[i] << " ";
	cout << endl;
	return 0;
}

Compilation message

bootfall.cpp:30:10: error: duplicate 'unsigned'
 unsigned unsigned LL dp[502 * 502*4];
          ^~~~~~~~