Submission #831471

# Submission time Handle Problem Language Result Execution time Memory
831471 2023-08-20T09:31:21 Z Chal1shkan Bootfall (IZhO17_bootfall) C++14
13 / 100
1000 ms 3364 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());

bitset <maxn * maxn> dp[maxn], bs;
int sum[maxn];

void ma1n (/* SABR */) {
    int n;
    cin >> n;
    int a[n + 3];
    int qwe = 0; dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    	qwe += a[i];
		dp[0] |= (dp[0] << a[i]);
	}
	if (qwe & 1 || (dp[0][qwe / 2] == 0)) {
		cout << 0 << nl;
	}
	else {
	    for (int i = 1; i <= n; ++i) {
	    	dp[i][0] = 1;
	        for (int j = 1; j <= n; ++j) {
	            if (j != i) {
	                dp[i] |= (dp[i] << a[j]);
	                sum[i] += a[j];
	            }
	        }
	    }
	    vector <int> ans;
	    for (int x = 1; x <= 25000; ++x) {
	    	bool ok = 1;
	        for (int i = 1; i <= n; ++i) {
		        if ((sum[i] + x) & 1) {
		        	ok = 0;
		        	break;
				}
	            bs = dp[i] | (dp[i] << x);
	        	if (bs[(sum[i] + x) / 2] == 0) {
	        		ok = 0;
					break;
				}
			}
	        if (ok) {
	            ans.pb(x);
	        }
	    }
	    cout << sz(ans) << nl;
	    for (int x : ans) cout << x << ' '; 
	}
}
 
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!!!
# Verdict Execution time Memory Grader output
1 Correct 91 ms 560 KB Output is correct
2 Correct 86 ms 624 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 86 ms 564 KB Output is correct
5 Correct 101 ms 800 KB Output is correct
6 Correct 87 ms 684 KB Output is correct
7 Correct 85 ms 596 KB Output is correct
8 Correct 101 ms 808 KB Output is correct
9 Correct 88 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 560 KB Output is correct
2 Correct 86 ms 624 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 86 ms 564 KB Output is correct
5 Correct 101 ms 800 KB Output is correct
6 Correct 87 ms 684 KB Output is correct
7 Correct 85 ms 596 KB Output is correct
8 Correct 101 ms 808 KB Output is correct
9 Correct 88 ms 748 KB Output is correct
10 Correct 99 ms 1364 KB Output is correct
11 Correct 115 ms 1364 KB Output is correct
12 Correct 92 ms 1364 KB Output is correct
13 Correct 93 ms 1236 KB Output is correct
14 Correct 118 ms 1236 KB Output is correct
15 Correct 114 ms 1300 KB Output is correct
16 Correct 118 ms 1360 KB Output is correct
17 Correct 105 ms 992 KB Output is correct
18 Correct 113 ms 1108 KB Output is correct
19 Correct 107 ms 1236 KB Output is correct
20 Correct 96 ms 1360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 560 KB Output is correct
2 Correct 86 ms 624 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 86 ms 564 KB Output is correct
5 Correct 101 ms 800 KB Output is correct
6 Correct 87 ms 684 KB Output is correct
7 Correct 85 ms 596 KB Output is correct
8 Correct 101 ms 808 KB Output is correct
9 Correct 88 ms 748 KB Output is correct
10 Correct 99 ms 1364 KB Output is correct
11 Correct 115 ms 1364 KB Output is correct
12 Correct 92 ms 1364 KB Output is correct
13 Correct 93 ms 1236 KB Output is correct
14 Correct 118 ms 1236 KB Output is correct
15 Correct 114 ms 1300 KB Output is correct
16 Correct 118 ms 1360 KB Output is correct
17 Correct 105 ms 992 KB Output is correct
18 Correct 113 ms 1108 KB Output is correct
19 Correct 107 ms 1236 KB Output is correct
20 Correct 96 ms 1360 KB Output is correct
21 Correct 876 ms 2432 KB Output is correct
22 Correct 988 ms 2864 KB Output is correct
23 Correct 524 ms 1988 KB Output is correct
24 Execution timed out 1077 ms 3364 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 91 ms 560 KB Output is correct
2 Correct 86 ms 624 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 86 ms 564 KB Output is correct
5 Correct 101 ms 800 KB Output is correct
6 Correct 87 ms 684 KB Output is correct
7 Correct 85 ms 596 KB Output is correct
8 Correct 101 ms 808 KB Output is correct
9 Correct 88 ms 748 KB Output is correct
10 Correct 99 ms 1364 KB Output is correct
11 Correct 115 ms 1364 KB Output is correct
12 Correct 92 ms 1364 KB Output is correct
13 Correct 93 ms 1236 KB Output is correct
14 Correct 118 ms 1236 KB Output is correct
15 Correct 114 ms 1300 KB Output is correct
16 Correct 118 ms 1360 KB Output is correct
17 Correct 105 ms 992 KB Output is correct
18 Correct 113 ms 1108 KB Output is correct
19 Correct 107 ms 1236 KB Output is correct
20 Correct 96 ms 1360 KB Output is correct
21 Correct 876 ms 2432 KB Output is correct
22 Correct 988 ms 2864 KB Output is correct
23 Correct 524 ms 1988 KB Output is correct
24 Execution timed out 1077 ms 3364 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 91 ms 560 KB Output is correct
2 Correct 86 ms 624 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 86 ms 564 KB Output is correct
5 Correct 101 ms 800 KB Output is correct
6 Correct 87 ms 684 KB Output is correct
7 Correct 85 ms 596 KB Output is correct
8 Correct 101 ms 808 KB Output is correct
9 Correct 88 ms 748 KB Output is correct
10 Correct 99 ms 1364 KB Output is correct
11 Correct 115 ms 1364 KB Output is correct
12 Correct 92 ms 1364 KB Output is correct
13 Correct 93 ms 1236 KB Output is correct
14 Correct 118 ms 1236 KB Output is correct
15 Correct 114 ms 1300 KB Output is correct
16 Correct 118 ms 1360 KB Output is correct
17 Correct 105 ms 992 KB Output is correct
18 Correct 113 ms 1108 KB Output is correct
19 Correct 107 ms 1236 KB Output is correct
20 Correct 96 ms 1360 KB Output is correct
21 Correct 876 ms 2432 KB Output is correct
22 Correct 988 ms 2864 KB Output is correct
23 Correct 524 ms 1988 KB Output is correct
24 Execution timed out 1077 ms 3364 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 91 ms 560 KB Output is correct
2 Correct 86 ms 624 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 86 ms 564 KB Output is correct
5 Correct 101 ms 800 KB Output is correct
6 Correct 87 ms 684 KB Output is correct
7 Correct 85 ms 596 KB Output is correct
8 Correct 101 ms 808 KB Output is correct
9 Correct 88 ms 748 KB Output is correct
10 Correct 99 ms 1364 KB Output is correct
11 Correct 115 ms 1364 KB Output is correct
12 Correct 92 ms 1364 KB Output is correct
13 Correct 93 ms 1236 KB Output is correct
14 Correct 118 ms 1236 KB Output is correct
15 Correct 114 ms 1300 KB Output is correct
16 Correct 118 ms 1360 KB Output is correct
17 Correct 105 ms 992 KB Output is correct
18 Correct 113 ms 1108 KB Output is correct
19 Correct 107 ms 1236 KB Output is correct
20 Correct 96 ms 1360 KB Output is correct
21 Correct 876 ms 2432 KB Output is correct
22 Correct 988 ms 2864 KB Output is correct
23 Correct 524 ms 1988 KB Output is correct
24 Execution timed out 1077 ms 3364 KB Time limit exceeded
25 Halted 0 ms 0 KB -