답안 #501595

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
501595 2022-01-04T06:53:17 Z mansur Bootfall (IZhO17_bootfall) C++17
100 / 100
325 ms 5824 KB
#include<bits/stdc++.h>	
 
#pragma optimize ("g",on)
#pragma GCC optimize ("inline")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("03")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
#pragma comment(linker, "/stack:200000000")

//01001101 01100001 01101011 01101000 01100001  01100111 01100001 01111001 

using namespace std;

#define all(a) a.begin(), a.end()                                                   
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define pb push_back
#define sz(a) a.size()
#define nl '\n'
#define popb pop_back()                                                                   
#define ld double
#define ull unsigned long long
#define ff first                                         
#define ss second  
#define fix fixed << setprecision
#define pii pair<int, int>                          
#define E exit (0)
#define int long long
 
const int inf = 1e9, N = 25e4 + 1, mod = 998244353;                    

vector<pii> dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};

int dp[N], cnt[N];

main() {                                                         
	//freopen("cowrect.in", "r", stdin);                                                                                     
	//freopen("cowrect.out", "w", stdout);                                                                                     
	ios_base::sync_with_stdio(NULL);                                                                                        
	cin.tie(NULL);  
	int n;
	cin >> n;
	int a[n + 1], sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int w = N - 1; w >= a[i]; w--) dp[w] += dp[w - a[i]]; 
	}
	if (!dp[sum / 2] || (sum & 1)) cout << 0, E;
	for (int i = 1; i <= n; i++) {
		for (int w = a[i]; w < N; w++) dp[w] -= dp[w - a[i]];
		sum -= a[i];
		for (int val = 0; val < N; val++) {
			sum += val;
			if (dp[sum / 2] && !(sum & 1)) cnt[val]++; 
			sum -= val;
		}
		sum += a[i];
		for (int w = N - 1; w >= a[i]; w--) dp[w] += dp[w - a[i]];
	}
	vector<int> ans;
	for (int val = 0; val < N; val++) if (cnt[val] == n) ans.pb(val); 
	cout << sz(ans) << nl;
	for (auto e: ans) cout << e << ' ';
}

Compilation message

bootfall.cpp:3: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    3 | #pragma optimize ("g",on)
      | 
bootfall.cpp:9: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    9 | #pragma comment(linker, "/stack:200000000")
      | 
bootfall.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2252 KB Output is correct
2 Correct 7 ms 2252 KB Output is correct
3 Correct 2 ms 2252 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 9 ms 2252 KB Output is correct
6 Correct 7 ms 2252 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 9 ms 2252 KB Output is correct
9 Correct 8 ms 2252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2252 KB Output is correct
2 Correct 7 ms 2252 KB Output is correct
3 Correct 2 ms 2252 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 9 ms 2252 KB Output is correct
6 Correct 7 ms 2252 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 9 ms 2252 KB Output is correct
9 Correct 8 ms 2252 KB Output is correct
10 Correct 20 ms 2276 KB Output is correct
11 Correct 26 ms 2252 KB Output is correct
12 Correct 20 ms 2280 KB Output is correct
13 Correct 21 ms 2276 KB Output is correct
14 Correct 24 ms 2276 KB Output is correct
15 Correct 24 ms 2268 KB Output is correct
16 Correct 25 ms 2272 KB Output is correct
17 Correct 16 ms 2252 KB Output is correct
18 Correct 21 ms 2400 KB Output is correct
19 Correct 23 ms 2252 KB Output is correct
20 Correct 19 ms 2268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2252 KB Output is correct
2 Correct 7 ms 2252 KB Output is correct
3 Correct 2 ms 2252 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 9 ms 2252 KB Output is correct
6 Correct 7 ms 2252 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 9 ms 2252 KB Output is correct
9 Correct 8 ms 2252 KB Output is correct
10 Correct 20 ms 2276 KB Output is correct
11 Correct 26 ms 2252 KB Output is correct
12 Correct 20 ms 2280 KB Output is correct
13 Correct 21 ms 2276 KB Output is correct
14 Correct 24 ms 2276 KB Output is correct
15 Correct 24 ms 2268 KB Output is correct
16 Correct 25 ms 2272 KB Output is correct
17 Correct 16 ms 2252 KB Output is correct
18 Correct 21 ms 2400 KB Output is correct
19 Correct 23 ms 2252 KB Output is correct
20 Correct 19 ms 2268 KB Output is correct
21 Correct 42 ms 2280 KB Output is correct
22 Correct 47 ms 2252 KB Output is correct
23 Correct 33 ms 2288 KB Output is correct
24 Correct 61 ms 2308 KB Output is correct
25 Correct 59 ms 2320 KB Output is correct
26 Correct 61 ms 2328 KB Output is correct
27 Correct 60 ms 2332 KB Output is correct
28 Correct 60 ms 2340 KB Output is correct
29 Correct 60 ms 2332 KB Output is correct
30 Correct 63 ms 2280 KB Output is correct
31 Correct 59 ms 2312 KB Output is correct
32 Correct 68 ms 2292 KB Output is correct
33 Correct 60 ms 2240 KB Output is correct
34 Correct 61 ms 2264 KB Output is correct
35 Correct 61 ms 2272 KB Output is correct
36 Correct 67 ms 2288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2252 KB Output is correct
2 Correct 7 ms 2252 KB Output is correct
3 Correct 2 ms 2252 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 9 ms 2252 KB Output is correct
6 Correct 7 ms 2252 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 9 ms 2252 KB Output is correct
9 Correct 8 ms 2252 KB Output is correct
10 Correct 20 ms 2276 KB Output is correct
11 Correct 26 ms 2252 KB Output is correct
12 Correct 20 ms 2280 KB Output is correct
13 Correct 21 ms 2276 KB Output is correct
14 Correct 24 ms 2276 KB Output is correct
15 Correct 24 ms 2268 KB Output is correct
16 Correct 25 ms 2272 KB Output is correct
17 Correct 16 ms 2252 KB Output is correct
18 Correct 21 ms 2400 KB Output is correct
19 Correct 23 ms 2252 KB Output is correct
20 Correct 19 ms 2268 KB Output is correct
21 Correct 42 ms 2280 KB Output is correct
22 Correct 47 ms 2252 KB Output is correct
23 Correct 33 ms 2288 KB Output is correct
24 Correct 61 ms 2308 KB Output is correct
25 Correct 59 ms 2320 KB Output is correct
26 Correct 61 ms 2328 KB Output is correct
27 Correct 60 ms 2332 KB Output is correct
28 Correct 60 ms 2340 KB Output is correct
29 Correct 60 ms 2332 KB Output is correct
30 Correct 63 ms 2280 KB Output is correct
31 Correct 59 ms 2312 KB Output is correct
32 Correct 68 ms 2292 KB Output is correct
33 Correct 60 ms 2240 KB Output is correct
34 Correct 61 ms 2264 KB Output is correct
35 Correct 61 ms 2272 KB Output is correct
36 Correct 67 ms 2288 KB Output is correct
37 Correct 117 ms 2628 KB Output is correct
38 Correct 125 ms 2664 KB Output is correct
39 Correct 147 ms 2732 KB Output is correct
40 Correct 161 ms 2784 KB Output is correct
41 Correct 156 ms 2788 KB Output is correct
42 Correct 159 ms 2872 KB Output is correct
43 Correct 144 ms 3068 KB Output is correct
44 Correct 149 ms 3168 KB Output is correct
45 Correct 145 ms 3084 KB Output is correct
46 Correct 166 ms 2496 KB Output is correct
47 Correct 154 ms 2764 KB Output is correct
48 Correct 146 ms 3028 KB Output is correct
49 Correct 146 ms 2864 KB Output is correct
50 Correct 161 ms 2784 KB Output is correct
51 Correct 38 ms 2252 KB Output is correct
52 Correct 158 ms 3312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2252 KB Output is correct
2 Correct 7 ms 2252 KB Output is correct
3 Correct 2 ms 2252 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 9 ms 2252 KB Output is correct
6 Correct 7 ms 2252 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 9 ms 2252 KB Output is correct
9 Correct 8 ms 2252 KB Output is correct
10 Correct 20 ms 2276 KB Output is correct
11 Correct 26 ms 2252 KB Output is correct
12 Correct 20 ms 2280 KB Output is correct
13 Correct 21 ms 2276 KB Output is correct
14 Correct 24 ms 2276 KB Output is correct
15 Correct 24 ms 2268 KB Output is correct
16 Correct 25 ms 2272 KB Output is correct
17 Correct 16 ms 2252 KB Output is correct
18 Correct 21 ms 2400 KB Output is correct
19 Correct 23 ms 2252 KB Output is correct
20 Correct 19 ms 2268 KB Output is correct
21 Correct 42 ms 2280 KB Output is correct
22 Correct 47 ms 2252 KB Output is correct
23 Correct 33 ms 2288 KB Output is correct
24 Correct 61 ms 2308 KB Output is correct
25 Correct 59 ms 2320 KB Output is correct
26 Correct 61 ms 2328 KB Output is correct
27 Correct 60 ms 2332 KB Output is correct
28 Correct 60 ms 2340 KB Output is correct
29 Correct 60 ms 2332 KB Output is correct
30 Correct 63 ms 2280 KB Output is correct
31 Correct 59 ms 2312 KB Output is correct
32 Correct 68 ms 2292 KB Output is correct
33 Correct 60 ms 2240 KB Output is correct
34 Correct 61 ms 2264 KB Output is correct
35 Correct 61 ms 2272 KB Output is correct
36 Correct 67 ms 2288 KB Output is correct
37 Correct 117 ms 2628 KB Output is correct
38 Correct 125 ms 2664 KB Output is correct
39 Correct 147 ms 2732 KB Output is correct
40 Correct 161 ms 2784 KB Output is correct
41 Correct 156 ms 2788 KB Output is correct
42 Correct 159 ms 2872 KB Output is correct
43 Correct 144 ms 3068 KB Output is correct
44 Correct 149 ms 3168 KB Output is correct
45 Correct 145 ms 3084 KB Output is correct
46 Correct 166 ms 2496 KB Output is correct
47 Correct 154 ms 2764 KB Output is correct
48 Correct 146 ms 3028 KB Output is correct
49 Correct 146 ms 2864 KB Output is correct
50 Correct 161 ms 2784 KB Output is correct
51 Correct 38 ms 2252 KB Output is correct
52 Correct 158 ms 3312 KB Output is correct
53 Correct 175 ms 2996 KB Output is correct
54 Correct 220 ms 3288 KB Output is correct
55 Correct 200 ms 3932 KB Output is correct
56 Correct 177 ms 3144 KB Output is correct
57 Correct 201 ms 3932 KB Output is correct
58 Correct 211 ms 3292 KB Output is correct
59 Correct 202 ms 3400 KB Output is correct
60 Correct 52 ms 2252 KB Output is correct
61 Correct 208 ms 3676 KB Output is correct
62 Correct 186 ms 3768 KB Output is correct
63 Correct 189 ms 3828 KB Output is correct
64 Correct 185 ms 3936 KB Output is correct
65 Correct 189 ms 2628 KB Output is correct
66 Correct 185 ms 2776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 2252 KB Output is correct
2 Correct 7 ms 2252 KB Output is correct
3 Correct 2 ms 2252 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 9 ms 2252 KB Output is correct
6 Correct 7 ms 2252 KB Output is correct
7 Correct 5 ms 2252 KB Output is correct
8 Correct 9 ms 2252 KB Output is correct
9 Correct 8 ms 2252 KB Output is correct
10 Correct 20 ms 2276 KB Output is correct
11 Correct 26 ms 2252 KB Output is correct
12 Correct 20 ms 2280 KB Output is correct
13 Correct 21 ms 2276 KB Output is correct
14 Correct 24 ms 2276 KB Output is correct
15 Correct 24 ms 2268 KB Output is correct
16 Correct 25 ms 2272 KB Output is correct
17 Correct 16 ms 2252 KB Output is correct
18 Correct 21 ms 2400 KB Output is correct
19 Correct 23 ms 2252 KB Output is correct
20 Correct 19 ms 2268 KB Output is correct
21 Correct 42 ms 2280 KB Output is correct
22 Correct 47 ms 2252 KB Output is correct
23 Correct 33 ms 2288 KB Output is correct
24 Correct 61 ms 2308 KB Output is correct
25 Correct 59 ms 2320 KB Output is correct
26 Correct 61 ms 2328 KB Output is correct
27 Correct 60 ms 2332 KB Output is correct
28 Correct 60 ms 2340 KB Output is correct
29 Correct 60 ms 2332 KB Output is correct
30 Correct 63 ms 2280 KB Output is correct
31 Correct 59 ms 2312 KB Output is correct
32 Correct 68 ms 2292 KB Output is correct
33 Correct 60 ms 2240 KB Output is correct
34 Correct 61 ms 2264 KB Output is correct
35 Correct 61 ms 2272 KB Output is correct
36 Correct 67 ms 2288 KB Output is correct
37 Correct 117 ms 2628 KB Output is correct
38 Correct 125 ms 2664 KB Output is correct
39 Correct 147 ms 2732 KB Output is correct
40 Correct 161 ms 2784 KB Output is correct
41 Correct 156 ms 2788 KB Output is correct
42 Correct 159 ms 2872 KB Output is correct
43 Correct 144 ms 3068 KB Output is correct
44 Correct 149 ms 3168 KB Output is correct
45 Correct 145 ms 3084 KB Output is correct
46 Correct 166 ms 2496 KB Output is correct
47 Correct 154 ms 2764 KB Output is correct
48 Correct 146 ms 3028 KB Output is correct
49 Correct 146 ms 2864 KB Output is correct
50 Correct 161 ms 2784 KB Output is correct
51 Correct 38 ms 2252 KB Output is correct
52 Correct 158 ms 3312 KB Output is correct
53 Correct 175 ms 2996 KB Output is correct
54 Correct 220 ms 3288 KB Output is correct
55 Correct 200 ms 3932 KB Output is correct
56 Correct 177 ms 3144 KB Output is correct
57 Correct 201 ms 3932 KB Output is correct
58 Correct 211 ms 3292 KB Output is correct
59 Correct 202 ms 3400 KB Output is correct
60 Correct 52 ms 2252 KB Output is correct
61 Correct 208 ms 3676 KB Output is correct
62 Correct 186 ms 3768 KB Output is correct
63 Correct 189 ms 3828 KB Output is correct
64 Correct 185 ms 3936 KB Output is correct
65 Correct 189 ms 2628 KB Output is correct
66 Correct 185 ms 2776 KB Output is correct
67 Correct 242 ms 3548 KB Output is correct
68 Correct 81 ms 2252 KB Output is correct
69 Correct 325 ms 5456 KB Output is correct
70 Correct 299 ms 4296 KB Output is correct
71 Correct 319 ms 4176 KB Output is correct
72 Correct 294 ms 3236 KB Output is correct
73 Correct 309 ms 3228 KB Output is correct
74 Correct 289 ms 5660 KB Output is correct
75 Correct 303 ms 4928 KB Output is correct
76 Correct 280 ms 5668 KB Output is correct
77 Correct 288 ms 5824 KB Output is correct