답안 #490573

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
490573 2021-11-28T03:32:40 Z DeadlyCritic Bali Sculptures (APIO15_sculpture) C++17
100 / 100
910 ms 844 KB
#include <bits/stdc++.h>
// #pragma GCC optimize ("O2,unroll-loops")
// #pragma GCC optimize("no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define IOS ios::sync_with_stdio(0), cin.tie(), cout.tie();

#define fr first
#define sc second
#define all(v) v.begin(), v.end()
#define uni(v) sort(all(v)), v.erase(unique(all(v)), v.end())

// #define c0 (v << 1)
// #define c1 (c0 | 1)
// #define md ((l+r)>>1)

using namespace std;

typedef long long ll;

const int maxN = 2e3+7;
const int maxBt = 42;

ll pef[maxN];
int y[maxN];
bitset<maxN> dp[maxN];

inline ll range(int l, int r){
    return pef[r+1]-pef[l];
}

signed main(){IOS

    int n;
    int a, b;
    cin >> n >> a >> b;
    for(int i = 0; i < n; i++){
        cin >> y[i];
    }

    ll ans = 0;
    ll bads = 0;

    pef[0] = 0;
    for(int i = 0; i < n; i++)pef[i+1] = pef[i]+y[i];

    ll maxAns = 1ll << (maxBt+1);
    ll w = 1ll << maxBt;

    for(int bit = maxBt; bit >= 0; bit--){
        bads += w;

        for(int i = 0; i <= n; i++)for(int j = 0; j <= n; j++)dp[i][j] = 0;
        for(int i = a; i <= b; i++)dp[0][i] = 1;

        for(int i = 0; i < n; i++){
            for(int j = 0; j <= i; j++){
                if(range(j, i) >= maxAns)break;
                if((range(j, i) & bads) == 0){
                    dp[i+1] |= dp[j] >> 1;
                }
            }
        }

        if(dp[n][0] == 0){
            bads ^= w;
            ans ^= w;
        }
        w >>= 1;
    }

    cout << ans << '\n';
}

/*
6 1 3
8 1 2 1 5 4
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 216 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 2 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 2 ms 332 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 3 ms 332 KB Output is correct
32 Correct 3 ms 332 KB Output is correct
33 Correct 3 ms 332 KB Output is correct
34 Correct 3 ms 332 KB Output is correct
35 Correct 3 ms 332 KB Output is correct
36 Correct 4 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 4 ms 332 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 5 ms 344 KB Output is correct
19 Correct 3 ms 332 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
21 Correct 3 ms 332 KB Output is correct
22 Correct 3 ms 332 KB Output is correct
23 Correct 3 ms 332 KB Output is correct
24 Correct 3 ms 332 KB Output is correct
25 Correct 5 ms 344 KB Output is correct
26 Correct 7 ms 332 KB Output is correct
27 Correct 9 ms 332 KB Output is correct
28 Correct 11 ms 332 KB Output is correct
29 Correct 11 ms 352 KB Output is correct
30 Correct 13 ms 348 KB Output is correct
31 Correct 11 ms 332 KB Output is correct
32 Correct 11 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 292 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 2 ms 332 KB Output is correct
38 Correct 2 ms 204 KB Output is correct
39 Correct 2 ms 332 KB Output is correct
40 Correct 2 ms 332 KB Output is correct
41 Correct 3 ms 332 KB Output is correct
42 Correct 3 ms 332 KB Output is correct
43 Correct 3 ms 332 KB Output is correct
44 Correct 4 ms 332 KB Output is correct
45 Correct 3 ms 332 KB Output is correct
46 Correct 4 ms 332 KB Output is correct
47 Correct 4 ms 332 KB Output is correct
48 Correct 5 ms 356 KB Output is correct
49 Correct 10 ms 332 KB Output is correct
50 Correct 9 ms 356 KB Output is correct
51 Correct 12 ms 352 KB Output is correct
52 Correct 11 ms 352 KB Output is correct
53 Correct 12 ms 352 KB Output is correct
54 Correct 10 ms 332 KB Output is correct
55 Correct 10 ms 348 KB Output is correct
56 Correct 2 ms 332 KB Output is correct
57 Correct 2 ms 332 KB Output is correct
58 Correct 4 ms 332 KB Output is correct
59 Correct 4 ms 332 KB Output is correct
60 Correct 4 ms 356 KB Output is correct
61 Correct 4 ms 332 KB Output is correct
62 Correct 5 ms 332 KB Output is correct
63 Correct 5 ms 348 KB Output is correct
64 Correct 10 ms 332 KB Output is correct
65 Correct 1 ms 332 KB Output is correct
66 Correct 2 ms 332 KB Output is correct
67 Correct 4 ms 332 KB Output is correct
68 Correct 3 ms 332 KB Output is correct
69 Correct 6 ms 332 KB Output is correct
70 Correct 4 ms 352 KB Output is correct
71 Correct 4 ms 356 KB Output is correct
72 Correct 5 ms 332 KB Output is correct
73 Correct 5 ms 332 KB Output is correct
74 Correct 5 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 2 ms 272 KB Output is correct
27 Correct 3 ms 332 KB Output is correct
28 Correct 3 ms 332 KB Output is correct
29 Correct 3 ms 344 KB Output is correct
30 Correct 3 ms 332 KB Output is correct
31 Correct 3 ms 332 KB Output is correct
32 Correct 3 ms 332 KB Output is correct
33 Correct 3 ms 336 KB Output is correct
34 Correct 3 ms 336 KB Output is correct
35 Correct 5 ms 336 KB Output is correct
36 Correct 7 ms 336 KB Output is correct
37 Correct 10 ms 352 KB Output is correct
38 Correct 11 ms 356 KB Output is correct
39 Correct 12 ms 336 KB Output is correct
40 Correct 11 ms 336 KB Output is correct
41 Correct 15 ms 336 KB Output is correct
42 Correct 10 ms 356 KB Output is correct
43 Correct 2 ms 336 KB Output is correct
44 Correct 3 ms 336 KB Output is correct
45 Correct 3 ms 336 KB Output is correct
46 Correct 4 ms 336 KB Output is correct
47 Correct 3 ms 336 KB Output is correct
48 Correct 4 ms 336 KB Output is correct
49 Correct 5 ms 332 KB Output is correct
50 Correct 5 ms 332 KB Output is correct
51 Correct 4 ms 332 KB Output is correct
52 Correct 91 ms 460 KB Output is correct
53 Correct 144 ms 460 KB Output is correct
54 Correct 270 ms 588 KB Output is correct
55 Correct 245 ms 460 KB Output is correct
56 Correct 871 ms 824 KB Output is correct
57 Correct 857 ms 844 KB Output is correct
58 Correct 761 ms 824 KB Output is correct
59 Correct 750 ms 824 KB Output is correct
60 Correct 910 ms 836 KB Output is correct
61 Correct 5 ms 352 KB Output is correct
62 Correct 140 ms 460 KB Output is correct
63 Correct 253 ms 588 KB Output is correct
64 Correct 241 ms 584 KB Output is correct
65 Correct 428 ms 684 KB Output is correct
66 Correct 636 ms 760 KB Output is correct
67 Correct 860 ms 824 KB Output is correct
68 Correct 867 ms 824 KB Output is correct
69 Correct 814 ms 824 KB Output is correct