답안 #37426

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
37426 2017-12-25T12:23:12 Z HardNut Bootfall (IZhO17_bootfall) C++14
0 / 100
0 ms 3024 KB
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const int MX = 250100;

int n;
int a[600];
int fl[MX];

bitset<MX> bb;

int main() {
    freopen("bootfall.in", "r", stdin);
    freopen("bootfall.out", "w", stdout);
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", a + i);
	for (int i = 1; i < MX; ++i)
		fl[i] = 1;
	for (int i = -1; i < n; ++i) {
		int sum = 0;
		bb.reset();
		bb[0] = 1;
		for (int j = 0; j < n; ++j)
			if (i != j) {
				sum += a[j];
				bb |= (bb << a[j]);
			}
		if (i != -1) {
			for (int j = 1; j < MX; ++j) {
				if ((sum + j) % 2 == 1 || !bb[(sum + j) / 2])
					fl[j] = 0;
			}
		}
		else {
			if (sum % 2 == 1 || !bb[sum / 2]) {
				cout << 0 << "\n";
				return 0;
			}
		}
	}
	int cnt = 0;
	for (int i = 0; i < MX; ++i)
		cnt += fl[i];
	printf("%d\n", cnt);
	for (int i = 1; i < MX; ++i) {
		if (fl[i])
			cout << i << " ";
	}
	cout << "\n";
	return 0;
}


Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:32:39: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("bootfall.in", "r", stdin);
                                       ^
bootfall.cpp:33:41: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("bootfall.out", "w", stdout);
                                         ^
bootfall.cpp:34:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
bootfall.cpp:36:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", a + i);
                     ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 3024 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 3024 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 3024 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 3024 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 3024 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 3024 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -