답안 #625571

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
625571 2022-08-10T15:05:18 Z Do_you_copy Bootfall (IZhO17_bootfall) C++17
28 / 100
8 ms 2004 KB
#include <bits/stdc++.h>
//#define int long long
#define fi first
#define se second
#define pb push_back
#define faster ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
using ll = long long;
using ull = unsigned ll;
using ld = long double;
using pii = pair <int, int>;
using pil = pair <int, ll>;
using pli = pair <ll, int>;
using pll = pair <ll, ll>;
mt19937 Rand(chrono::steady_clock::now().time_since_epoch().count());

ll min(const ll &a, const ll &b){
    return (a < b) ? a : b;
}

ll max(const ll &a, const ll &b){
    return (a > b) ? a : b;
}

//const ll Mod = 1000000007;
//const ll Mod2 = 999999999989;
//only use when required
const int maxN = 502 + 1;
const int maxB = 25001;
int n;
int a[maxN];
int sum;
bitset <maxB> bit[5000];
int pos[maxN];
void build(int id, int l, int r){
    if (l == r){
        pos[r] = id;
        return;
    }
    int mid = (l + r) / 2;
    bit[id * 2 + 1] = bit[id * 2] = bit[id];
    for (int i = l; i <= mid; ++i){
        bit[id * 2 + 1] =  bit[id * 2 + 1] | (bit[id * 2 + 1] << a[i]);
    }
    for (int i = mid + 1; i <= r; ++i){
        bit[id * 2] = bit[id * 2] | (bit[id * 2] << a[i]);
    }
    build(id * 2, l, mid);
    build(id * 2 + 1, mid + 1, r);
}

void Init(){
    cin >> n;
    for (int i = 1; i <= n; ++i){
        cin >> a[i];
        sum += a[i];
    }
    bit[1][0] = 1;
    build(1, 1, n);
    bitset <maxB> S = bit[pos[1]] | (bit[pos[1]] << a[1]);
    if (sum % 2 || !S[sum / 2]){
        cout << 0;
        return;
    }
    vector <int> ans;
    for (int i = 1; i < maxB; ++i){
        bool flag = 0;
        for (int j = 1; j <= n; ++j){
            int cur = sum - a[j] + i;
            int t = cur / 2;
            if (cur % 2 || i > t || (!bit[pos[j]][t] && !bit[pos[j]][t - i])){
                flag = 1;
                break;
            }
        }
        if (!flag) ans.pb(i);
    }
    cout << ans.size() << "\n";
    for (int i: ans) cout << i << ' ';
}

#define debu
#define taskname "test"
signed main(){
    if (fopen(taskname".inp", "r")){
        freopen(taskname".inp", "r", stdin);
        #ifdef debug
        freopen(taskname".out", "w", stdout);
        #endif
    }
    faster;
    ll tt = 1;
    //cin >> tt;
    while (tt--){
        Init();
    }
    if (fopen("timeout.txt", "r")){
        ofstream timeout("timeout.txt");
        timeout << 1000 * double(clock()) / CLOCKS_PER_SEC;
        #ifndef debug
        cerr << "\nTime elapsed: " << 1000 * double(clock()) / CLOCKS_PER_SEC << "ms\n";
        #endif
    }
}

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:86:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   86 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 472 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 472 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 472 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 472 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 732 KB Output is correct
22 Correct 2 ms 852 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 2 ms 1108 KB Output is correct
25 Correct 3 ms 1104 KB Output is correct
26 Correct 3 ms 1160 KB Output is correct
27 Correct 2 ms 1208 KB Output is correct
28 Correct 3 ms 1108 KB Output is correct
29 Correct 2 ms 1108 KB Output is correct
30 Correct 2 ms 1108 KB Output is correct
31 Correct 2 ms 1108 KB Output is correct
32 Correct 2 ms 1108 KB Output is correct
33 Correct 2 ms 1108 KB Output is correct
34 Correct 2 ms 1108 KB Output is correct
35 Correct 2 ms 1108 KB Output is correct
36 Correct 2 ms 1044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 472 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 472 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 732 KB Output is correct
22 Correct 2 ms 852 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 2 ms 1108 KB Output is correct
25 Correct 3 ms 1104 KB Output is correct
26 Correct 3 ms 1160 KB Output is correct
27 Correct 2 ms 1208 KB Output is correct
28 Correct 3 ms 1108 KB Output is correct
29 Correct 2 ms 1108 KB Output is correct
30 Correct 2 ms 1108 KB Output is correct
31 Correct 2 ms 1108 KB Output is correct
32 Correct 2 ms 1108 KB Output is correct
33 Correct 2 ms 1108 KB Output is correct
34 Correct 2 ms 1108 KB Output is correct
35 Correct 2 ms 1108 KB Output is correct
36 Correct 2 ms 1044 KB Output is correct
37 Correct 8 ms 2004 KB Output is correct
38 Correct 8 ms 2004 KB Output is correct
39 Incorrect 3 ms 1876 KB Output isn't correct
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 472 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 472 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 732 KB Output is correct
22 Correct 2 ms 852 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 2 ms 1108 KB Output is correct
25 Correct 3 ms 1104 KB Output is correct
26 Correct 3 ms 1160 KB Output is correct
27 Correct 2 ms 1208 KB Output is correct
28 Correct 3 ms 1108 KB Output is correct
29 Correct 2 ms 1108 KB Output is correct
30 Correct 2 ms 1108 KB Output is correct
31 Correct 2 ms 1108 KB Output is correct
32 Correct 2 ms 1108 KB Output is correct
33 Correct 2 ms 1108 KB Output is correct
34 Correct 2 ms 1108 KB Output is correct
35 Correct 2 ms 1108 KB Output is correct
36 Correct 2 ms 1044 KB Output is correct
37 Correct 8 ms 2004 KB Output is correct
38 Correct 8 ms 2004 KB Output is correct
39 Incorrect 3 ms 1876 KB Output isn't correct
40 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 472 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 472 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 732 KB Output is correct
22 Correct 2 ms 852 KB Output is correct
23 Correct 1 ms 724 KB Output is correct
24 Correct 2 ms 1108 KB Output is correct
25 Correct 3 ms 1104 KB Output is correct
26 Correct 3 ms 1160 KB Output is correct
27 Correct 2 ms 1208 KB Output is correct
28 Correct 3 ms 1108 KB Output is correct
29 Correct 2 ms 1108 KB Output is correct
30 Correct 2 ms 1108 KB Output is correct
31 Correct 2 ms 1108 KB Output is correct
32 Correct 2 ms 1108 KB Output is correct
33 Correct 2 ms 1108 KB Output is correct
34 Correct 2 ms 1108 KB Output is correct
35 Correct 2 ms 1108 KB Output is correct
36 Correct 2 ms 1044 KB Output is correct
37 Correct 8 ms 2004 KB Output is correct
38 Correct 8 ms 2004 KB Output is correct
39 Incorrect 3 ms 1876 KB Output isn't correct
40 Halted 0 ms 0 KB -