답안 #92723

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
92723 2019-01-04T11:34:25 Z toloraia Bootfall (IZhO17_bootfall) C++14
28 / 100
1000 ms 1016 KB
#include <bits/stdc++.h>
#pragma GCC("O3")
using namespace std;

const int N = 505, M = 250005;

int n;
int a[N];
bool F[M];
int A[M], B[M];
int np, nn;
int S;
int ANS[M];
int ans[M];

int main()
{
    cin>>n;
    for (int i = 1; i <= n; i++){
        cin>>a[i];
        S += a[i];
    }
    sort (a + 1, a + n + 1);
    bool ok = 0;
    for (int i = 2; i <= n; i++)
        if ((a[i] - a[i - 1]) % 2 == 1)
            ok = 1;
    if (S % 2 == 1)
        ok = 1;
    if (ok){
        cout<<0<<endl;
        return 0;
    }
    F[0] = 1;
    np = 1;
    A[1] = 0;
    for (int i = 1; i <= n; i++){
        nn = 0;
        for (int j = 1; j <= np; j++)
            if (F[A[j] + a[i]] == 0){
                B[++nn] = A[j] + a[i];
                F[B[nn]] = 1;
            }
        for (int j = 1; j <= nn; j++)
            A[++np] = B[j];
    }
    if (F[S / 2] == 0){
        cout<<0<<endl;
        return 0;
    }
    //cout<<S<<endl;
    for (int I = 1; I <= n; I++){
        for (int i = 0; i <= S; i++)
            F[i] = 0;
        F[0] = 1;
        np = 1;
        A[1] = 0;
        for (int i = 1; i <= n; i++){
            if (i == I)
                continue;
            nn = 0;
            for (int j = 1; j <= np; j++)
                if (F[A[j] + a[i]] == 0){
                    B[++nn] = A[j] + a[i];
                    F[B[nn]] = 1;
                }
            for (int j = 1; j <= nn; j++)
                A[++np] = B[j];
        }
        for (int i = 1; i <= S; i++)
            ans[i] = 0;
        for (int i = 1; i <= np; i++){
            ans[abs (S - a[I] - 2 * A[i])] = 1;
            //cout<<I<<" "<<A[i]<<" "<<abs (S - a[I] - 2 * A[i])<<endl;
        }
        for (int i = 1; i <= S; i++)
            ANS[i] += ans[i];
        //cout<<endl;
    }
    np = 0;
    for (int i = 1; i <= S; i++)
        if (ANS[i] == n)
            A[++np] = i;
    cout<<np<<endl;
    for (int i = 1; i <= np; i++)
        cout<<A[i]<<" ";
    cout<<endl;
    return 0;
}

Compilation message

bootfall.cpp:2:0: warning: ignoring #pragma GCC  [-Wunknown-pragmas]
 #pragma GCC("O3")
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 1 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 1 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 252 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 13 ms 276 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 1 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 252 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 13 ms 276 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 6 ms 424 KB Output is correct
22 Correct 8 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 14 ms 376 KB Output is correct
25 Correct 25 ms 504 KB Output is correct
26 Correct 23 ms 504 KB Output is correct
27 Correct 16 ms 376 KB Output is correct
28 Correct 13 ms 504 KB Output is correct
29 Correct 15 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 29 ms 504 KB Output is correct
32 Correct 16 ms 504 KB Output is correct
33 Correct 4 ms 504 KB Output is correct
34 Correct 4 ms 504 KB Output is correct
35 Correct 12 ms 504 KB Output is correct
36 Correct 15 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 1 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 252 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 13 ms 276 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 6 ms 424 KB Output is correct
22 Correct 8 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 14 ms 376 KB Output is correct
25 Correct 25 ms 504 KB Output is correct
26 Correct 23 ms 504 KB Output is correct
27 Correct 16 ms 376 KB Output is correct
28 Correct 13 ms 504 KB Output is correct
29 Correct 15 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 29 ms 504 KB Output is correct
32 Correct 16 ms 504 KB Output is correct
33 Correct 4 ms 504 KB Output is correct
34 Correct 4 ms 504 KB Output is correct
35 Correct 12 ms 504 KB Output is correct
36 Correct 15 ms 376 KB Output is correct
37 Correct 267 ms 760 KB Output is correct
38 Correct 307 ms 760 KB Output is correct
39 Correct 34 ms 888 KB Output is correct
40 Correct 697 ms 796 KB Output is correct
41 Correct 44 ms 1016 KB Output is correct
42 Correct 623 ms 888 KB Output is correct
43 Execution timed out 1089 ms 1016 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 1 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 252 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 13 ms 276 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 6 ms 424 KB Output is correct
22 Correct 8 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 14 ms 376 KB Output is correct
25 Correct 25 ms 504 KB Output is correct
26 Correct 23 ms 504 KB Output is correct
27 Correct 16 ms 376 KB Output is correct
28 Correct 13 ms 504 KB Output is correct
29 Correct 15 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 29 ms 504 KB Output is correct
32 Correct 16 ms 504 KB Output is correct
33 Correct 4 ms 504 KB Output is correct
34 Correct 4 ms 504 KB Output is correct
35 Correct 12 ms 504 KB Output is correct
36 Correct 15 ms 376 KB Output is correct
37 Correct 267 ms 760 KB Output is correct
38 Correct 307 ms 760 KB Output is correct
39 Correct 34 ms 888 KB Output is correct
40 Correct 697 ms 796 KB Output is correct
41 Correct 44 ms 1016 KB Output is correct
42 Correct 623 ms 888 KB Output is correct
43 Execution timed out 1089 ms 1016 KB Time limit exceeded
44 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 1 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 252 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 13 ms 276 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 6 ms 424 KB Output is correct
22 Correct 8 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 14 ms 376 KB Output is correct
25 Correct 25 ms 504 KB Output is correct
26 Correct 23 ms 504 KB Output is correct
27 Correct 16 ms 376 KB Output is correct
28 Correct 13 ms 504 KB Output is correct
29 Correct 15 ms 376 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 29 ms 504 KB Output is correct
32 Correct 16 ms 504 KB Output is correct
33 Correct 4 ms 504 KB Output is correct
34 Correct 4 ms 504 KB Output is correct
35 Correct 12 ms 504 KB Output is correct
36 Correct 15 ms 376 KB Output is correct
37 Correct 267 ms 760 KB Output is correct
38 Correct 307 ms 760 KB Output is correct
39 Correct 34 ms 888 KB Output is correct
40 Correct 697 ms 796 KB Output is correct
41 Correct 44 ms 1016 KB Output is correct
42 Correct 623 ms 888 KB Output is correct
43 Execution timed out 1089 ms 1016 KB Time limit exceeded
44 Halted 0 ms 0 KB -