답안 #1055046

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055046 2024-08-12T14:12:31 Z Khanhcsp2 Bootfall (IZhO17_bootfall) C++14
100 / 100
970 ms 1364 KB
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
#define el '\n'
#define fi first
#define sc second

#define pii pair<int, int>
#define all(v) v.begin(), v.end()
using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
const int mod=1e9+7;
const int N=511;
int n, a[N], sum;
bitset<N*N> bs, cur, s1, s2;
void sol()
{
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    bs&=0;
    bs[0]=1;
    for(int i=1;i<=n;i++)
    {
        bs|=bs<<(a[i]);
        sum+=a[i];
    }
    if(sum&1 || bs[sum/2]==0)
    {
        cout << 0 << el;
        return;
    }
    int ch1=1, ch2=1;
    s1.set();
    s2.set();
    s2[0]=0;
    for(int i=1;i<=n;i++)
    {
        cur&=0;
        cur[0]=1;
        for(int j=1;j<=n;j++) if(j!=i) cur|=(cur<<(a[j]));
        int ss=sum-a[i];
        if(ss%2==0)
        {
            s2&=(cur>>(ss/2));
            if(ch1)
            {
               s1&=0;
               ch1=0;
            }
        }
        else
        {
            s1&=(cur>>(ss/2+1));
            if(ch2)
            {
                s2&=0;
                ch2=0;
            }
        }
    }
    cout << s1.count()+s2.count() << el;
    for(int i=0;i<N*N;i++)
    {
        if(s2[i]) cout << i*2 << el;
        if(s1[i]) cout << i*2+1 << el;
    }
}
signed main()
{
//    freopen("divisor.INP", "r", stdin);
//    freopen("divisor.OUT", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin >> t;
    while(t--)
    {
        sol();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 4 ms 604 KB Output is correct
11 Correct 4 ms 604 KB Output is correct
12 Correct 4 ms 604 KB Output is correct
13 Correct 3 ms 644 KB Output is correct
14 Correct 4 ms 600 KB Output is correct
15 Correct 3 ms 608 KB Output is correct
16 Correct 4 ms 604 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 3 ms 600 KB Output is correct
19 Correct 3 ms 480 KB Output is correct
20 Correct 4 ms 644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 4 ms 604 KB Output is correct
11 Correct 4 ms 604 KB Output is correct
12 Correct 4 ms 604 KB Output is correct
13 Correct 3 ms 644 KB Output is correct
14 Correct 4 ms 600 KB Output is correct
15 Correct 3 ms 608 KB Output is correct
16 Correct 4 ms 604 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 3 ms 600 KB Output is correct
19 Correct 3 ms 480 KB Output is correct
20 Correct 4 ms 644 KB Output is correct
21 Correct 16 ms 604 KB Output is correct
22 Correct 21 ms 604 KB Output is correct
23 Correct 11 ms 600 KB Output is correct
24 Correct 34 ms 604 KB Output is correct
25 Correct 34 ms 632 KB Output is correct
26 Correct 39 ms 640 KB Output is correct
27 Correct 38 ms 616 KB Output is correct
28 Correct 38 ms 604 KB Output is correct
29 Correct 37 ms 604 KB Output is correct
30 Correct 37 ms 604 KB Output is correct
31 Correct 38 ms 636 KB Output is correct
32 Correct 42 ms 600 KB Output is correct
33 Correct 38 ms 616 KB Output is correct
34 Correct 44 ms 604 KB Output is correct
35 Correct 38 ms 600 KB Output is correct
36 Correct 38 ms 636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 4 ms 604 KB Output is correct
11 Correct 4 ms 604 KB Output is correct
12 Correct 4 ms 604 KB Output is correct
13 Correct 3 ms 644 KB Output is correct
14 Correct 4 ms 600 KB Output is correct
15 Correct 3 ms 608 KB Output is correct
16 Correct 4 ms 604 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 3 ms 600 KB Output is correct
19 Correct 3 ms 480 KB Output is correct
20 Correct 4 ms 644 KB Output is correct
21 Correct 16 ms 604 KB Output is correct
22 Correct 21 ms 604 KB Output is correct
23 Correct 11 ms 600 KB Output is correct
24 Correct 34 ms 604 KB Output is correct
25 Correct 34 ms 632 KB Output is correct
26 Correct 39 ms 640 KB Output is correct
27 Correct 38 ms 616 KB Output is correct
28 Correct 38 ms 604 KB Output is correct
29 Correct 37 ms 604 KB Output is correct
30 Correct 37 ms 604 KB Output is correct
31 Correct 38 ms 636 KB Output is correct
32 Correct 42 ms 600 KB Output is correct
33 Correct 38 ms 616 KB Output is correct
34 Correct 44 ms 604 KB Output is correct
35 Correct 38 ms 600 KB Output is correct
36 Correct 38 ms 636 KB Output is correct
37 Correct 151 ms 632 KB Output is correct
38 Correct 148 ms 600 KB Output is correct
39 Correct 223 ms 624 KB Output is correct
40 Correct 267 ms 628 KB Output is correct
41 Correct 266 ms 636 KB Output is correct
42 Correct 227 ms 604 KB Output is correct
43 Correct 241 ms 604 KB Output is correct
44 Correct 239 ms 620 KB Output is correct
45 Correct 228 ms 604 KB Output is correct
46 Correct 291 ms 604 KB Output is correct
47 Correct 251 ms 604 KB Output is correct
48 Correct 232 ms 600 KB Output is correct
49 Correct 231 ms 604 KB Output is correct
50 Correct 231 ms 628 KB Output is correct
51 Correct 2 ms 348 KB Output is correct
52 Correct 265 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 4 ms 604 KB Output is correct
11 Correct 4 ms 604 KB Output is correct
12 Correct 4 ms 604 KB Output is correct
13 Correct 3 ms 644 KB Output is correct
14 Correct 4 ms 600 KB Output is correct
15 Correct 3 ms 608 KB Output is correct
16 Correct 4 ms 604 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 3 ms 600 KB Output is correct
19 Correct 3 ms 480 KB Output is correct
20 Correct 4 ms 644 KB Output is correct
21 Correct 16 ms 604 KB Output is correct
22 Correct 21 ms 604 KB Output is correct
23 Correct 11 ms 600 KB Output is correct
24 Correct 34 ms 604 KB Output is correct
25 Correct 34 ms 632 KB Output is correct
26 Correct 39 ms 640 KB Output is correct
27 Correct 38 ms 616 KB Output is correct
28 Correct 38 ms 604 KB Output is correct
29 Correct 37 ms 604 KB Output is correct
30 Correct 37 ms 604 KB Output is correct
31 Correct 38 ms 636 KB Output is correct
32 Correct 42 ms 600 KB Output is correct
33 Correct 38 ms 616 KB Output is correct
34 Correct 44 ms 604 KB Output is correct
35 Correct 38 ms 600 KB Output is correct
36 Correct 38 ms 636 KB Output is correct
37 Correct 151 ms 632 KB Output is correct
38 Correct 148 ms 600 KB Output is correct
39 Correct 223 ms 624 KB Output is correct
40 Correct 267 ms 628 KB Output is correct
41 Correct 266 ms 636 KB Output is correct
42 Correct 227 ms 604 KB Output is correct
43 Correct 241 ms 604 KB Output is correct
44 Correct 239 ms 620 KB Output is correct
45 Correct 228 ms 604 KB Output is correct
46 Correct 291 ms 604 KB Output is correct
47 Correct 251 ms 604 KB Output is correct
48 Correct 232 ms 600 KB Output is correct
49 Correct 231 ms 604 KB Output is correct
50 Correct 231 ms 628 KB Output is correct
51 Correct 2 ms 348 KB Output is correct
52 Correct 265 ms 632 KB Output is correct
53 Correct 336 ms 856 KB Output is correct
54 Correct 448 ms 616 KB Output is correct
55 Correct 453 ms 848 KB Output is correct
56 Correct 348 ms 632 KB Output is correct
57 Correct 448 ms 884 KB Output is correct
58 Correct 454 ms 636 KB Output is correct
59 Correct 452 ms 616 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 451 ms 624 KB Output is correct
62 Correct 399 ms 872 KB Output is correct
63 Correct 376 ms 848 KB Output is correct
64 Correct 370 ms 892 KB Output is correct
65 Correct 365 ms 604 KB Output is correct
66 Correct 354 ms 616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 4 ms 604 KB Output is correct
11 Correct 4 ms 604 KB Output is correct
12 Correct 4 ms 604 KB Output is correct
13 Correct 3 ms 644 KB Output is correct
14 Correct 4 ms 600 KB Output is correct
15 Correct 3 ms 608 KB Output is correct
16 Correct 4 ms 604 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 3 ms 600 KB Output is correct
19 Correct 3 ms 480 KB Output is correct
20 Correct 4 ms 644 KB Output is correct
21 Correct 16 ms 604 KB Output is correct
22 Correct 21 ms 604 KB Output is correct
23 Correct 11 ms 600 KB Output is correct
24 Correct 34 ms 604 KB Output is correct
25 Correct 34 ms 632 KB Output is correct
26 Correct 39 ms 640 KB Output is correct
27 Correct 38 ms 616 KB Output is correct
28 Correct 38 ms 604 KB Output is correct
29 Correct 37 ms 604 KB Output is correct
30 Correct 37 ms 604 KB Output is correct
31 Correct 38 ms 636 KB Output is correct
32 Correct 42 ms 600 KB Output is correct
33 Correct 38 ms 616 KB Output is correct
34 Correct 44 ms 604 KB Output is correct
35 Correct 38 ms 600 KB Output is correct
36 Correct 38 ms 636 KB Output is correct
37 Correct 151 ms 632 KB Output is correct
38 Correct 148 ms 600 KB Output is correct
39 Correct 223 ms 624 KB Output is correct
40 Correct 267 ms 628 KB Output is correct
41 Correct 266 ms 636 KB Output is correct
42 Correct 227 ms 604 KB Output is correct
43 Correct 241 ms 604 KB Output is correct
44 Correct 239 ms 620 KB Output is correct
45 Correct 228 ms 604 KB Output is correct
46 Correct 291 ms 604 KB Output is correct
47 Correct 251 ms 604 KB Output is correct
48 Correct 232 ms 600 KB Output is correct
49 Correct 231 ms 604 KB Output is correct
50 Correct 231 ms 628 KB Output is correct
51 Correct 2 ms 348 KB Output is correct
52 Correct 265 ms 632 KB Output is correct
53 Correct 336 ms 856 KB Output is correct
54 Correct 448 ms 616 KB Output is correct
55 Correct 453 ms 848 KB Output is correct
56 Correct 348 ms 632 KB Output is correct
57 Correct 448 ms 884 KB Output is correct
58 Correct 454 ms 636 KB Output is correct
59 Correct 452 ms 616 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 451 ms 624 KB Output is correct
62 Correct 399 ms 872 KB Output is correct
63 Correct 376 ms 848 KB Output is correct
64 Correct 370 ms 892 KB Output is correct
65 Correct 365 ms 604 KB Output is correct
66 Correct 354 ms 616 KB Output is correct
67 Correct 590 ms 852 KB Output is correct
68 Correct 3 ms 344 KB Output is correct
69 Correct 970 ms 1136 KB Output is correct
70 Correct 940 ms 872 KB Output is correct
71 Correct 937 ms 872 KB Output is correct
72 Correct 912 ms 616 KB Output is correct
73 Correct 910 ms 624 KB Output is correct
74 Correct 910 ms 1364 KB Output is correct
75 Correct 931 ms 1108 KB Output is correct
76 Correct 917 ms 1148 KB Output is correct
77 Correct 927 ms 1144 KB Output is correct