답안 #38794

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
38794 2018-01-06T15:16:48 Z DenXman111 Bootfall (IZhO17_bootfall) C++14
0 / 100
0 ms 7068 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
#include <iomanip>
#include <set>
#include <sstream>
#include <ctime>
#include <bitset>

#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))
#define sqr(a) (a)*(a)
#define p_b push_back
#define m_p make_pair
#define fi first
#define se second
#define endl "\n"

typedef long long ll;
typedef long double ld;
const int MAXINT = 2147483640;
const ll MAXLL = 9223372036854775800LL;
const ll MAXN = 323456;
const ll MOD = 1000000123;
const ll MAXANS = 1000000007;
using namespace std;

int a[MAXN], ans[MAXN], dp[MAXN], d[MAXN];
int main()
{
//    freopen("bootfall.in", "r", stdin);
//    freopen("bootfall.out", "w", stdout);
    int n, i, j, sum = 0, x = 0;
    cin >> n;
    dp[0] = 1;
    if (sum % 2 == 1 || dp[sum / 2] == 0) return cout << 0 << endl, 0;
    for (j = 0; j <= sum; j++) d[j] = dp[j];
    bitset < 25555 > dp, now, zero;
    dp[0] = 1;
    for (i = 1; i <= n; i++){
        cin >> a[i];
        now = dp;
        dp <<= a[i];
        dp |= now;
        sum += a[i];
    }
    for (i = 1; i <= n; i++){
        dp &= zero;
        dp[0] = 1;
        for (j = 1; j <= n; j++) if (j != i){
            now = dp;
            dp <<= a[j];
            dp |= now;
        }
        for (j = 0; j <= sum; j++){
            x = abs(sum - j - a[i] - j);
            if (dp[j] == 1 && ans[x] == i - 1) ans[x] = i;
        }
    }
    vector < int > v;
    for (i = 0; i <= sum; i++) if (ans[i] == n) v.p_b(i);
    cout << v.size() << endl;
    for (i = 0; i < v.size(); i++) cout << v[i] << " ";
    return 0;
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:69:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i = 0; i < v.size(); i++) cout << v[i] << " ";
                   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 7068 KB Output is correct
2 Correct 0 ms 7068 KB Output is correct
3 Incorrect 0 ms 7068 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 7068 KB Output is correct
2 Correct 0 ms 7068 KB Output is correct
3 Incorrect 0 ms 7068 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 7068 KB Output is correct
2 Correct 0 ms 7068 KB Output is correct
3 Incorrect 0 ms 7068 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 7068 KB Output is correct
2 Correct 0 ms 7068 KB Output is correct
3 Incorrect 0 ms 7068 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 7068 KB Output is correct
2 Correct 0 ms 7068 KB Output is correct
3 Incorrect 0 ms 7068 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 7068 KB Output is correct
2 Correct 0 ms 7068 KB Output is correct
3 Incorrect 0 ms 7068 KB Output isn't correct
4 Halted 0 ms 0 KB -