답안 #831598

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
831598 2023-08-20T11:07:18 Z Chal1shkan Bootfall (IZhO17_bootfall) C++14
28 / 100
29 ms 816 KB
//Bismillahir-Rahmanir-Rahim

# include <bits/stdc++.h>

# define pb push_back
# define ff first
# define ss second
# define nl "\n"
# define sz(x) ((int)(x).size())
# define all(x) (x).begin(), (x).end()
# define deb(x) cerr << #x  << " = " << x << endl; 
# define pll pair <ll, ll>
# define pii pair <int, int>
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const ll maxn = 5e2 + 3;
const ll inf = 2e18 + 0;
const ll mod = 1e9 + 7;
const ll dx[] = {-1, 1, 0, 0};
const ll dy[] = {0, 0, -1, 1};

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, a[maxn], sum;
ll dp[maxn * maxn];
bitset <maxn * maxn> ok;

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

void del (int x) {
	sum -= x;
	for (int i = 0; i <= sum; ++i) {
		dp[i + x] -= dp[i];
	}
}

void ma1n (/* SABR */) {
    cin >> n;
    dp[0] = 1;
    add(0);
    for (int i = 1; i <= n; ++i) {
    	cin >> a[i];
    	add(a[i]);
	}
	if (sum & 1 || !dp[sum / 2]) {
		cout << 0 << nl;
	}
	else {
		for (int x = 1; x <= 25000; ++x) {
			ok[x] = 1;
		}
		for (int i = 1; i <= n; ++i) {
			del(a[i]);
			for (int x = 1; x <= 25000; ++x){
				if ((sum + x) & 1 || !dp[(sum + x) / 2]) {
					ok[x] = 0;
				}
			}
			add(a[i]);
		}
		cout << ok.count() << nl;
		for (ll x = ok._Find_first(); x <= 25000; x = ok._Find_next(x)) {
			cout << x << ' ';
		}
		cout << nl;
	}
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
//  freopen("file.in", "r", stdin);
//  freopen("file.out", "w", stdout);
    int ttt = 1;
//  cin >> ttt;
    for (int test = 1; test <= ttt; ++test) {
//      cout << "Case " << test << ":" << '\n';
        ma1n();
    }
    return 0;
}

// 998batrr | BbIWEJI 3A TObOU!!!
// tourist  | BbIWEJI 3A TObOU!!!
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 4 ms 340 KB Output is correct
22 Correct 4 ms 336 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 5 ms 340 KB Output is correct
25 Correct 6 ms 308 KB Output is correct
26 Correct 6 ms 336 KB Output is correct
27 Correct 6 ms 336 KB Output is correct
28 Correct 6 ms 332 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 5 ms 340 KB Output is correct
31 Correct 6 ms 396 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 6 ms 340 KB Output is correct
34 Correct 6 ms 340 KB Output is correct
35 Correct 6 ms 340 KB Output is correct
36 Correct 5 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 4 ms 340 KB Output is correct
22 Correct 4 ms 336 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 5 ms 340 KB Output is correct
25 Correct 6 ms 308 KB Output is correct
26 Correct 6 ms 336 KB Output is correct
27 Correct 6 ms 336 KB Output is correct
28 Correct 6 ms 332 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 5 ms 340 KB Output is correct
31 Correct 6 ms 396 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 6 ms 340 KB Output is correct
34 Correct 6 ms 340 KB Output is correct
35 Correct 6 ms 340 KB Output is correct
36 Correct 5 ms 340 KB Output is correct
37 Correct 11 ms 524 KB Output is correct
38 Correct 11 ms 468 KB Output is correct
39 Incorrect 29 ms 816 KB Output isn't correct
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 4 ms 340 KB Output is correct
22 Correct 4 ms 336 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 5 ms 340 KB Output is correct
25 Correct 6 ms 308 KB Output is correct
26 Correct 6 ms 336 KB Output is correct
27 Correct 6 ms 336 KB Output is correct
28 Correct 6 ms 332 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 5 ms 340 KB Output is correct
31 Correct 6 ms 396 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 6 ms 340 KB Output is correct
34 Correct 6 ms 340 KB Output is correct
35 Correct 6 ms 340 KB Output is correct
36 Correct 5 ms 340 KB Output is correct
37 Correct 11 ms 524 KB Output is correct
38 Correct 11 ms 468 KB Output is correct
39 Incorrect 29 ms 816 KB Output isn't correct
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 4 ms 340 KB Output is correct
22 Correct 4 ms 336 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 5 ms 340 KB Output is correct
25 Correct 6 ms 308 KB Output is correct
26 Correct 6 ms 336 KB Output is correct
27 Correct 6 ms 336 KB Output is correct
28 Correct 6 ms 332 KB Output is correct
29 Correct 6 ms 340 KB Output is correct
30 Correct 5 ms 340 KB Output is correct
31 Correct 6 ms 396 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 6 ms 340 KB Output is correct
34 Correct 6 ms 340 KB Output is correct
35 Correct 6 ms 340 KB Output is correct
36 Correct 5 ms 340 KB Output is correct
37 Correct 11 ms 524 KB Output is correct
38 Correct 11 ms 468 KB Output is correct
39 Incorrect 29 ms 816 KB Output isn't correct
40 Halted 0 ms 0 KB -