답안 #167626

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167626 2019-12-09T06:33:04 Z Rakhmand Bootfall (IZhO17_bootfall) C++14
28 / 100
1000 ms 65752 KB
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//
 
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
 
#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer return cout << 0, 0;
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)
 
const int MXN = 4e5 + 200;
const long long MNN = 4e2 + 200;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;
 
typedef long long llong;
typedef unsigned long long ullong;
 
using namespace std;
 
int n, k, a[MXN], cnt, pos[200000], num[100000];
int sum = 0;
vector<int> v;

bitset<62000> dp[510][510];

void precalc(){
    bitset<62000> p;
    p[0] = 1;
    for(int i = 1; i <= n; i++){
        p |= p << a[i];
    }
    if(p[sum / 2] == 0) {
        cout << 0;
        exit(0);
    }
    int kek = 0;
    for(int i = 0; i <= sum; i++){
        if(p[i] == 1){
            pos[i] = kek;
            num[kek] = i;
            kek++;
        }
        else{
            pos[i] = -1;
        }
    }
    dp[0][1][0] = 1;
    for(int no = 1; no <= n; no++){
        dp[no][0][0] = 1;
        for(int i = 1; i <= n; i++){
            for(int j = 0; j <= pos[sum]; j++){
                dp[no][i][j] = dp[no][i - 1][j];
                int l = num[j];
                if(num[j] - a[i] >= 0 && pos[l - a[i]] != -1 && i != no){
                    if(dp[no][i - 1][pos[l - a[i]]] == 1)
                        dp[no][i][j] = 1;
                }
            }
        }
    }
}






int main () {
    ios;
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        sum += a[i];
        cnt += a[i] % 2;
    }
    if(sum % 2 == 1) no_answer;
    if(cnt != 0 && cnt != n) no_answer;
    precalc();
    for(int i = a[1] % 2; i <= sum; i += 2){
        bool ok = 1;
        for(int j = 1; j <= n; j++){
            if((sum + i - a[j]) / 2 - i < 0 || pos[(sum + i - a[j]) / 2 - i] == -1){
                ok = 0;
                break;
            }
            if(dp[j][n][pos[(sum + i - a[j]) / 2 - i]] == 0){
                ok = 0;
                break;
            }
        }
        if(ok == 1) v.pb(i);
    }
    cout << v.size() << nl;
    for(int i = 0; i < v.size(); i++){
        cout << v[i] << ' ';
    }
    
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:128:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < v.size(); i++){
                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 1016 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 3 ms 1016 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 1016 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 3 ms 1016 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 6 ms 4216 KB Output is correct
11 Correct 8 ms 4216 KB Output is correct
12 Correct 7 ms 4216 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 7 ms 3704 KB Output is correct
15 Correct 7 ms 3704 KB Output is correct
16 Correct 7 ms 4216 KB Output is correct
17 Correct 5 ms 1784 KB Output is correct
18 Correct 5 ms 2936 KB Output is correct
19 Correct 6 ms 3320 KB Output is correct
20 Correct 6 ms 4188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 1016 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 3 ms 1016 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 6 ms 4216 KB Output is correct
11 Correct 8 ms 4216 KB Output is correct
12 Correct 7 ms 4216 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 7 ms 3704 KB Output is correct
15 Correct 7 ms 3704 KB Output is correct
16 Correct 7 ms 4216 KB Output is correct
17 Correct 5 ms 1784 KB Output is correct
18 Correct 5 ms 2936 KB Output is correct
19 Correct 6 ms 3320 KB Output is correct
20 Correct 6 ms 4188 KB Output is correct
21 Correct 106 ms 18904 KB Output is correct
22 Correct 124 ms 25208 KB Output is correct
23 Correct 44 ms 11524 KB Output is correct
24 Correct 250 ms 41572 KB Output is correct
25 Correct 355 ms 44280 KB Output is correct
26 Correct 431 ms 50640 KB Output is correct
27 Correct 254 ms 46328 KB Output is correct
28 Correct 234 ms 45756 KB Output is correct
29 Correct 296 ms 46940 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 433 ms 50396 KB Output is correct
32 Correct 291 ms 46968 KB Output is correct
33 Correct 55 ms 41336 KB Output is correct
34 Correct 56 ms 41312 KB Output is correct
35 Correct 254 ms 46168 KB Output is correct
36 Correct 286 ms 46968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 1016 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 3 ms 1016 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 6 ms 4216 KB Output is correct
11 Correct 8 ms 4216 KB Output is correct
12 Correct 7 ms 4216 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 7 ms 3704 KB Output is correct
15 Correct 7 ms 3704 KB Output is correct
16 Correct 7 ms 4216 KB Output is correct
17 Correct 5 ms 1784 KB Output is correct
18 Correct 5 ms 2936 KB Output is correct
19 Correct 6 ms 3320 KB Output is correct
20 Correct 6 ms 4188 KB Output is correct
21 Correct 106 ms 18904 KB Output is correct
22 Correct 124 ms 25208 KB Output is correct
23 Correct 44 ms 11524 KB Output is correct
24 Correct 250 ms 41572 KB Output is correct
25 Correct 355 ms 44280 KB Output is correct
26 Correct 431 ms 50640 KB Output is correct
27 Correct 254 ms 46328 KB Output is correct
28 Correct 234 ms 45756 KB Output is correct
29 Correct 296 ms 46940 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 433 ms 50396 KB Output is correct
32 Correct 291 ms 46968 KB Output is correct
33 Correct 55 ms 41336 KB Output is correct
34 Correct 56 ms 41312 KB Output is correct
35 Correct 254 ms 46168 KB Output is correct
36 Correct 286 ms 46968 KB Output is correct
37 Execution timed out 1048 ms 65752 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 1016 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 3 ms 1016 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 6 ms 4216 KB Output is correct
11 Correct 8 ms 4216 KB Output is correct
12 Correct 7 ms 4216 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 7 ms 3704 KB Output is correct
15 Correct 7 ms 3704 KB Output is correct
16 Correct 7 ms 4216 KB Output is correct
17 Correct 5 ms 1784 KB Output is correct
18 Correct 5 ms 2936 KB Output is correct
19 Correct 6 ms 3320 KB Output is correct
20 Correct 6 ms 4188 KB Output is correct
21 Correct 106 ms 18904 KB Output is correct
22 Correct 124 ms 25208 KB Output is correct
23 Correct 44 ms 11524 KB Output is correct
24 Correct 250 ms 41572 KB Output is correct
25 Correct 355 ms 44280 KB Output is correct
26 Correct 431 ms 50640 KB Output is correct
27 Correct 254 ms 46328 KB Output is correct
28 Correct 234 ms 45756 KB Output is correct
29 Correct 296 ms 46940 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 433 ms 50396 KB Output is correct
32 Correct 291 ms 46968 KB Output is correct
33 Correct 55 ms 41336 KB Output is correct
34 Correct 56 ms 41312 KB Output is correct
35 Correct 254 ms 46168 KB Output is correct
36 Correct 286 ms 46968 KB Output is correct
37 Execution timed out 1048 ms 65752 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 3 ms 1016 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 3 ms 1016 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 6 ms 4216 KB Output is correct
11 Correct 8 ms 4216 KB Output is correct
12 Correct 7 ms 4216 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 7 ms 3704 KB Output is correct
15 Correct 7 ms 3704 KB Output is correct
16 Correct 7 ms 4216 KB Output is correct
17 Correct 5 ms 1784 KB Output is correct
18 Correct 5 ms 2936 KB Output is correct
19 Correct 6 ms 3320 KB Output is correct
20 Correct 6 ms 4188 KB Output is correct
21 Correct 106 ms 18904 KB Output is correct
22 Correct 124 ms 25208 KB Output is correct
23 Correct 44 ms 11524 KB Output is correct
24 Correct 250 ms 41572 KB Output is correct
25 Correct 355 ms 44280 KB Output is correct
26 Correct 431 ms 50640 KB Output is correct
27 Correct 254 ms 46328 KB Output is correct
28 Correct 234 ms 45756 KB Output is correct
29 Correct 296 ms 46940 KB Output is correct
30 Correct 2 ms 376 KB Output is correct
31 Correct 433 ms 50396 KB Output is correct
32 Correct 291 ms 46968 KB Output is correct
33 Correct 55 ms 41336 KB Output is correct
34 Correct 56 ms 41312 KB Output is correct
35 Correct 254 ms 46168 KB Output is correct
36 Correct 286 ms 46968 KB Output is correct
37 Execution timed out 1048 ms 65752 KB Time limit exceeded
38 Halted 0 ms 0 KB -