Submission #831469

# Submission time Handle Problem Language Result Execution time Memory
831469 2023-08-20T09:30:09 Z Chal1shkan Bootfall (IZhO17_bootfall) C++14
13 / 100
1000 ms 4532 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 * 2> 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 175 ms 804 KB Output is correct
2 Correct 174 ms 936 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 177 ms 812 KB Output is correct
5 Correct 205 ms 1308 KB Output is correct
6 Correct 176 ms 1064 KB Output is correct
7 Correct 179 ms 936 KB Output is correct
8 Correct 208 ms 1320 KB Output is correct
9 Correct 180 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 175 ms 804 KB Output is correct
2 Correct 174 ms 936 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 177 ms 812 KB Output is correct
5 Correct 205 ms 1308 KB Output is correct
6 Correct 176 ms 1064 KB Output is correct
7 Correct 179 ms 936 KB Output is correct
8 Correct 208 ms 1320 KB Output is correct
9 Correct 180 ms 1108 KB Output is correct
10 Correct 192 ms 2388 KB Output is correct
11 Correct 246 ms 2420 KB Output is correct
12 Correct 189 ms 2420 KB Output is correct
13 Correct 182 ms 2168 KB Output is correct
14 Correct 241 ms 2300 KB Output is correct
15 Correct 223 ms 2296 KB Output is correct
16 Correct 239 ms 2388 KB Output is correct
17 Correct 196 ms 1676 KB Output is correct
18 Correct 218 ms 2004 KB Output is correct
19 Correct 220 ms 2172 KB Output is correct
20 Correct 191 ms 2420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 175 ms 804 KB Output is correct
2 Correct 174 ms 936 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 177 ms 812 KB Output is correct
5 Correct 205 ms 1308 KB Output is correct
6 Correct 176 ms 1064 KB Output is correct
7 Correct 179 ms 936 KB Output is correct
8 Correct 208 ms 1320 KB Output is correct
9 Correct 180 ms 1108 KB Output is correct
10 Correct 192 ms 2388 KB Output is correct
11 Correct 246 ms 2420 KB Output is correct
12 Correct 189 ms 2420 KB Output is correct
13 Correct 182 ms 2168 KB Output is correct
14 Correct 241 ms 2300 KB Output is correct
15 Correct 223 ms 2296 KB Output is correct
16 Correct 239 ms 2388 KB Output is correct
17 Correct 196 ms 1676 KB Output is correct
18 Correct 218 ms 2004 KB Output is correct
19 Correct 220 ms 2172 KB Output is correct
20 Correct 191 ms 2420 KB Output is correct
21 Execution timed out 1076 ms 4532 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 175 ms 804 KB Output is correct
2 Correct 174 ms 936 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 177 ms 812 KB Output is correct
5 Correct 205 ms 1308 KB Output is correct
6 Correct 176 ms 1064 KB Output is correct
7 Correct 179 ms 936 KB Output is correct
8 Correct 208 ms 1320 KB Output is correct
9 Correct 180 ms 1108 KB Output is correct
10 Correct 192 ms 2388 KB Output is correct
11 Correct 246 ms 2420 KB Output is correct
12 Correct 189 ms 2420 KB Output is correct
13 Correct 182 ms 2168 KB Output is correct
14 Correct 241 ms 2300 KB Output is correct
15 Correct 223 ms 2296 KB Output is correct
16 Correct 239 ms 2388 KB Output is correct
17 Correct 196 ms 1676 KB Output is correct
18 Correct 218 ms 2004 KB Output is correct
19 Correct 220 ms 2172 KB Output is correct
20 Correct 191 ms 2420 KB Output is correct
21 Execution timed out 1076 ms 4532 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 175 ms 804 KB Output is correct
2 Correct 174 ms 936 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 177 ms 812 KB Output is correct
5 Correct 205 ms 1308 KB Output is correct
6 Correct 176 ms 1064 KB Output is correct
7 Correct 179 ms 936 KB Output is correct
8 Correct 208 ms 1320 KB Output is correct
9 Correct 180 ms 1108 KB Output is correct
10 Correct 192 ms 2388 KB Output is correct
11 Correct 246 ms 2420 KB Output is correct
12 Correct 189 ms 2420 KB Output is correct
13 Correct 182 ms 2168 KB Output is correct
14 Correct 241 ms 2300 KB Output is correct
15 Correct 223 ms 2296 KB Output is correct
16 Correct 239 ms 2388 KB Output is correct
17 Correct 196 ms 1676 KB Output is correct
18 Correct 218 ms 2004 KB Output is correct
19 Correct 220 ms 2172 KB Output is correct
20 Correct 191 ms 2420 KB Output is correct
21 Execution timed out 1076 ms 4532 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 175 ms 804 KB Output is correct
2 Correct 174 ms 936 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 177 ms 812 KB Output is correct
5 Correct 205 ms 1308 KB Output is correct
6 Correct 176 ms 1064 KB Output is correct
7 Correct 179 ms 936 KB Output is correct
8 Correct 208 ms 1320 KB Output is correct
9 Correct 180 ms 1108 KB Output is correct
10 Correct 192 ms 2388 KB Output is correct
11 Correct 246 ms 2420 KB Output is correct
12 Correct 189 ms 2420 KB Output is correct
13 Correct 182 ms 2168 KB Output is correct
14 Correct 241 ms 2300 KB Output is correct
15 Correct 223 ms 2296 KB Output is correct
16 Correct 239 ms 2388 KB Output is correct
17 Correct 196 ms 1676 KB Output is correct
18 Correct 218 ms 2004 KB Output is correct
19 Correct 220 ms 2172 KB Output is correct
20 Correct 191 ms 2420 KB Output is correct
21 Execution timed out 1076 ms 4532 KB Time limit exceeded
22 Halted 0 ms 0 KB -