답안 #1055020

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055020 2024-08-12T14:03:21 Z Khanhcsp2 Bootfall (IZhO17_bootfall) C++14
65 / 100
1000 ms 856 KB
#include<bits/stdc++.h>
#define el '\n'
#define fi first
#define sc second
#define int ll
#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 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 520 KB Output is correct
5 Correct 2 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 2 ms 520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 520 KB Output is correct
5 Correct 2 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 2 ms 520 KB Output is correct
10 Correct 6 ms 604 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 6 ms 604 KB Output is correct
13 Correct 4 ms 604 KB Output is correct
14 Correct 5 ms 648 KB Output is correct
15 Correct 5 ms 604 KB Output is correct
16 Correct 6 ms 604 KB Output is correct
17 Correct 3 ms 600 KB Output is correct
18 Correct 4 ms 604 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 6 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 520 KB Output is correct
5 Correct 2 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 2 ms 520 KB Output is correct
10 Correct 6 ms 604 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 6 ms 604 KB Output is correct
13 Correct 4 ms 604 KB Output is correct
14 Correct 5 ms 648 KB Output is correct
15 Correct 5 ms 604 KB Output is correct
16 Correct 6 ms 604 KB Output is correct
17 Correct 3 ms 600 KB Output is correct
18 Correct 4 ms 604 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 6 ms 604 KB Output is correct
21 Correct 26 ms 600 KB Output is correct
22 Correct 33 ms 604 KB Output is correct
23 Correct 17 ms 600 KB Output is correct
24 Correct 52 ms 600 KB Output is correct
25 Correct 51 ms 620 KB Output is correct
26 Correct 59 ms 636 KB Output is correct
27 Correct 58 ms 600 KB Output is correct
28 Correct 62 ms 616 KB Output is correct
29 Correct 59 ms 600 KB Output is correct
30 Correct 59 ms 604 KB Output is correct
31 Correct 61 ms 600 KB Output is correct
32 Correct 77 ms 604 KB Output is correct
33 Correct 62 ms 600 KB Output is correct
34 Correct 74 ms 856 KB Output is correct
35 Correct 60 ms 600 KB Output is correct
36 Correct 59 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 520 KB Output is correct
5 Correct 2 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 2 ms 520 KB Output is correct
10 Correct 6 ms 604 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 6 ms 604 KB Output is correct
13 Correct 4 ms 604 KB Output is correct
14 Correct 5 ms 648 KB Output is correct
15 Correct 5 ms 604 KB Output is correct
16 Correct 6 ms 604 KB Output is correct
17 Correct 3 ms 600 KB Output is correct
18 Correct 4 ms 604 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 6 ms 604 KB Output is correct
21 Correct 26 ms 600 KB Output is correct
22 Correct 33 ms 604 KB Output is correct
23 Correct 17 ms 600 KB Output is correct
24 Correct 52 ms 600 KB Output is correct
25 Correct 51 ms 620 KB Output is correct
26 Correct 59 ms 636 KB Output is correct
27 Correct 58 ms 600 KB Output is correct
28 Correct 62 ms 616 KB Output is correct
29 Correct 59 ms 600 KB Output is correct
30 Correct 59 ms 604 KB Output is correct
31 Correct 61 ms 600 KB Output is correct
32 Correct 77 ms 604 KB Output is correct
33 Correct 62 ms 600 KB Output is correct
34 Correct 74 ms 856 KB Output is correct
35 Correct 60 ms 600 KB Output is correct
36 Correct 59 ms 604 KB Output is correct
37 Correct 235 ms 640 KB Output is correct
38 Correct 229 ms 600 KB Output is correct
39 Correct 371 ms 600 KB Output is correct
40 Correct 432 ms 604 KB Output is correct
41 Correct 424 ms 600 KB Output is correct
42 Correct 400 ms 640 KB Output is correct
43 Correct 356 ms 600 KB Output is correct
44 Correct 355 ms 600 KB Output is correct
45 Correct 371 ms 624 KB Output is correct
46 Correct 446 ms 600 KB Output is correct
47 Correct 372 ms 604 KB Output is correct
48 Correct 358 ms 600 KB Output is correct
49 Correct 372 ms 624 KB Output is correct
50 Correct 369 ms 636 KB Output is correct
51 Correct 2 ms 344 KB Output is correct
52 Correct 425 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 520 KB Output is correct
5 Correct 2 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 2 ms 520 KB Output is correct
10 Correct 6 ms 604 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 6 ms 604 KB Output is correct
13 Correct 4 ms 604 KB Output is correct
14 Correct 5 ms 648 KB Output is correct
15 Correct 5 ms 604 KB Output is correct
16 Correct 6 ms 604 KB Output is correct
17 Correct 3 ms 600 KB Output is correct
18 Correct 4 ms 604 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 6 ms 604 KB Output is correct
21 Correct 26 ms 600 KB Output is correct
22 Correct 33 ms 604 KB Output is correct
23 Correct 17 ms 600 KB Output is correct
24 Correct 52 ms 600 KB Output is correct
25 Correct 51 ms 620 KB Output is correct
26 Correct 59 ms 636 KB Output is correct
27 Correct 58 ms 600 KB Output is correct
28 Correct 62 ms 616 KB Output is correct
29 Correct 59 ms 600 KB Output is correct
30 Correct 59 ms 604 KB Output is correct
31 Correct 61 ms 600 KB Output is correct
32 Correct 77 ms 604 KB Output is correct
33 Correct 62 ms 600 KB Output is correct
34 Correct 74 ms 856 KB Output is correct
35 Correct 60 ms 600 KB Output is correct
36 Correct 59 ms 604 KB Output is correct
37 Correct 235 ms 640 KB Output is correct
38 Correct 229 ms 600 KB Output is correct
39 Correct 371 ms 600 KB Output is correct
40 Correct 432 ms 604 KB Output is correct
41 Correct 424 ms 600 KB Output is correct
42 Correct 400 ms 640 KB Output is correct
43 Correct 356 ms 600 KB Output is correct
44 Correct 355 ms 600 KB Output is correct
45 Correct 371 ms 624 KB Output is correct
46 Correct 446 ms 600 KB Output is correct
47 Correct 372 ms 604 KB Output is correct
48 Correct 358 ms 600 KB Output is correct
49 Correct 372 ms 624 KB Output is correct
50 Correct 369 ms 636 KB Output is correct
51 Correct 2 ms 344 KB Output is correct
52 Correct 425 ms 600 KB Output is correct
53 Correct 535 ms 600 KB Output is correct
54 Correct 724 ms 600 KB Output is correct
55 Correct 763 ms 848 KB Output is correct
56 Correct 538 ms 604 KB Output is correct
57 Correct 742 ms 852 KB Output is correct
58 Correct 773 ms 600 KB Output is correct
59 Correct 749 ms 628 KB Output is correct
60 Correct 2 ms 344 KB Output is correct
61 Correct 768 ms 852 KB Output is correct
62 Correct 605 ms 852 KB Output is correct
63 Correct 620 ms 852 KB Output is correct
64 Correct 596 ms 852 KB Output is correct
65 Correct 585 ms 604 KB Output is correct
66 Correct 558 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 520 KB Output is correct
5 Correct 2 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 2 ms 520 KB Output is correct
10 Correct 6 ms 604 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 6 ms 604 KB Output is correct
13 Correct 4 ms 604 KB Output is correct
14 Correct 5 ms 648 KB Output is correct
15 Correct 5 ms 604 KB Output is correct
16 Correct 6 ms 604 KB Output is correct
17 Correct 3 ms 600 KB Output is correct
18 Correct 4 ms 604 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 6 ms 604 KB Output is correct
21 Correct 26 ms 600 KB Output is correct
22 Correct 33 ms 604 KB Output is correct
23 Correct 17 ms 600 KB Output is correct
24 Correct 52 ms 600 KB Output is correct
25 Correct 51 ms 620 KB Output is correct
26 Correct 59 ms 636 KB Output is correct
27 Correct 58 ms 600 KB Output is correct
28 Correct 62 ms 616 KB Output is correct
29 Correct 59 ms 600 KB Output is correct
30 Correct 59 ms 604 KB Output is correct
31 Correct 61 ms 600 KB Output is correct
32 Correct 77 ms 604 KB Output is correct
33 Correct 62 ms 600 KB Output is correct
34 Correct 74 ms 856 KB Output is correct
35 Correct 60 ms 600 KB Output is correct
36 Correct 59 ms 604 KB Output is correct
37 Correct 235 ms 640 KB Output is correct
38 Correct 229 ms 600 KB Output is correct
39 Correct 371 ms 600 KB Output is correct
40 Correct 432 ms 604 KB Output is correct
41 Correct 424 ms 600 KB Output is correct
42 Correct 400 ms 640 KB Output is correct
43 Correct 356 ms 600 KB Output is correct
44 Correct 355 ms 600 KB Output is correct
45 Correct 371 ms 624 KB Output is correct
46 Correct 446 ms 600 KB Output is correct
47 Correct 372 ms 604 KB Output is correct
48 Correct 358 ms 600 KB Output is correct
49 Correct 372 ms 624 KB Output is correct
50 Correct 369 ms 636 KB Output is correct
51 Correct 2 ms 344 KB Output is correct
52 Correct 425 ms 600 KB Output is correct
53 Correct 535 ms 600 KB Output is correct
54 Correct 724 ms 600 KB Output is correct
55 Correct 763 ms 848 KB Output is correct
56 Correct 538 ms 604 KB Output is correct
57 Correct 742 ms 852 KB Output is correct
58 Correct 773 ms 600 KB Output is correct
59 Correct 749 ms 628 KB Output is correct
60 Correct 2 ms 344 KB Output is correct
61 Correct 768 ms 852 KB Output is correct
62 Correct 605 ms 852 KB Output is correct
63 Correct 620 ms 852 KB Output is correct
64 Correct 596 ms 852 KB Output is correct
65 Correct 585 ms 604 KB Output is correct
66 Correct 558 ms 604 KB Output is correct
67 Correct 929 ms 620 KB Output is correct
68 Correct 3 ms 348 KB Output is correct
69 Execution timed out 1093 ms 604 KB Time limit exceeded
70 Halted 0 ms 0 KB -