답안 #20157

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20157 2016-02-29T09:31:04 Z murat Bali Sculptures (APIO15_sculpture) C++
100 / 100
371 ms 34648 KB
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define orta (bas + son >> 1)
#define sag (k + k + 1)
#define sol (k + k)
#define endl '\n'
#define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++)
#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)
#define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--)
#define mp make_pair
#define nd second
#define st first
#define type(x) __typeof(x.begin())

typedef pair < int ,int > pii;

typedef long long ll;

const long long linf = 1e18+5;
const int mod = (int) 1e9 + 7;
const int logN = 17;
const int inf = 1e9;
const int N = 2e5 + 5;

int n, a, b, dp[N], dp2[105][105], aa[N], can[2001][2001], temp[2001][2001];
ll pre[2001], ans;

int f1() {
    ROF(i, n, 1) {
        dp[i] = inf;
        FOR(j, i, n)
            if(can[i][j])
                dp[i] = min(dp[i], dp[j + 1] + 1);
    }
    return dp[1] <= b;
}

int f2() {
    dp2[n + 1][0] = 1;
    ROF(i, n, 1) {
        FOR(k, 0, b) {
            dp2[i][k+1] = 0;
            FOR(j, i, n)
                if(can[i][j] && dp2[j+1][k]) {
                    dp2[i][k+1] = 1;
                    break;
                }
        }
    }
    FOR(i, a, b)
        if(dp2[1][i])
            return 1;
    return 0;
}

int main() {

    scanf("%d %d %d", &n, &a, &b);

    int last = log2(1000000000LL * n);

    FOR(i, 1, n) {
        scanf("%d", &aa[i]);
        pre[i] = aa[i] + pre[i-1];
    }

    FOR(i, 1, n)
        FOR(j, i, n)
            can[i][j] = 1;

    ROF(i, last, 0) {
        ll cur = (1ll << (ll) i);
        FOR(i, 1, n)
            FOR(j, i, n) {
                temp[i][j] = can[i][j];
                if(can[i][j] && !((pre[j] - pre[i - 1]) & cur))
                    can[i][j] = 1;
                else can[i][j] = 0;
            }
        if(a == 1 && f1()) continue;
        if(a != 1 && f2()) continue;
        ans += cur;
        FOR(i, 1, n)
            FOR(j, i, n)
                can[i][j] = temp[i][j];
    }

    cout << ans << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 34648 KB Output is correct
2 Correct 0 ms 34648 KB Output is correct
3 Correct 0 ms 34648 KB Output is correct
4 Correct 0 ms 34648 KB Output is correct
5 Correct 0 ms 34648 KB Output is correct
6 Correct 0 ms 34648 KB Output is correct
7 Correct 0 ms 34648 KB Output is correct
8 Correct 0 ms 34648 KB Output is correct
9 Correct 0 ms 34648 KB Output is correct
10 Correct 0 ms 34648 KB Output is correct
11 Correct 0 ms 34648 KB Output is correct
12 Correct 0 ms 34648 KB Output is correct
13 Correct 0 ms 34648 KB Output is correct
14 Correct 1 ms 34648 KB Output is correct
15 Correct 0 ms 34648 KB Output is correct
16 Correct 0 ms 34648 KB Output is correct
17 Correct 0 ms 34648 KB Output is correct
18 Correct 0 ms 34648 KB Output is correct
19 Correct 0 ms 34648 KB Output is correct
20 Correct 0 ms 34648 KB Output is correct
21 Correct 0 ms 34648 KB Output is correct
22 Correct 0 ms 34648 KB Output is correct
23 Correct 0 ms 34648 KB Output is correct
24 Correct 0 ms 34648 KB Output is correct
25 Correct 0 ms 34648 KB Output is correct
26 Correct 1 ms 34648 KB Output is correct
27 Correct 0 ms 34648 KB Output is correct
28 Correct 0 ms 34648 KB Output is correct
29 Correct 0 ms 34648 KB Output is correct
30 Correct 0 ms 34648 KB Output is correct
31 Correct 0 ms 34648 KB Output is correct
32 Correct 0 ms 34648 KB Output is correct
33 Correct 0 ms 34648 KB Output is correct
34 Correct 0 ms 34648 KB Output is correct
35 Correct 0 ms 34648 KB Output is correct
36 Correct 0 ms 34648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 34648 KB Output is correct
2 Correct 0 ms 34648 KB Output is correct
3 Correct 0 ms 34648 KB Output is correct
4 Correct 0 ms 34648 KB Output is correct
5 Correct 0 ms 34648 KB Output is correct
6 Correct 0 ms 34648 KB Output is correct
7 Correct 0 ms 34648 KB Output is correct
8 Correct 0 ms 34648 KB Output is correct
9 Correct 0 ms 34648 KB Output is correct
10 Correct 0 ms 34648 KB Output is correct
11 Correct 0 ms 34648 KB Output is correct
12 Correct 0 ms 34648 KB Output is correct
13 Correct 0 ms 34648 KB Output is correct
14 Correct 0 ms 34648 KB Output is correct
15 Correct 0 ms 34648 KB Output is correct
16 Correct 0 ms 34648 KB Output is correct
17 Correct 0 ms 34648 KB Output is correct
18 Correct 0 ms 34648 KB Output is correct
19 Correct 0 ms 34648 KB Output is correct
20 Correct 0 ms 34648 KB Output is correct
21 Correct 0 ms 34648 KB Output is correct
22 Correct 0 ms 34648 KB Output is correct
23 Correct 0 ms 34648 KB Output is correct
24 Correct 0 ms 34648 KB Output is correct
25 Correct 0 ms 34648 KB Output is correct
26 Correct 1 ms 34648 KB Output is correct
27 Correct 0 ms 34648 KB Output is correct
28 Correct 1 ms 34648 KB Output is correct
29 Correct 0 ms 34648 KB Output is correct
30 Correct 0 ms 34648 KB Output is correct
31 Correct 0 ms 34648 KB Output is correct
32 Correct 0 ms 34648 KB Output is correct
33 Correct 0 ms 34648 KB Output is correct
34 Correct 0 ms 34648 KB Output is correct
35 Correct 1 ms 34648 KB Output is correct
36 Correct 0 ms 34648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 34648 KB Output is correct
2 Correct 0 ms 34648 KB Output is correct
3 Correct 0 ms 34648 KB Output is correct
4 Correct 0 ms 34648 KB Output is correct
5 Correct 0 ms 34648 KB Output is correct
6 Correct 0 ms 34648 KB Output is correct
7 Correct 0 ms 34648 KB Output is correct
8 Correct 0 ms 34648 KB Output is correct
9 Correct 0 ms 34648 KB Output is correct
10 Correct 0 ms 34648 KB Output is correct
11 Correct 0 ms 34648 KB Output is correct
12 Correct 0 ms 34648 KB Output is correct
13 Correct 0 ms 34648 KB Output is correct
14 Correct 0 ms 34648 KB Output is correct
15 Correct 0 ms 34648 KB Output is correct
16 Correct 0 ms 34648 KB Output is correct
17 Correct 0 ms 34648 KB Output is correct
18 Correct 0 ms 34648 KB Output is correct
19 Correct 0 ms 34648 KB Output is correct
20 Correct 0 ms 34648 KB Output is correct
21 Correct 0 ms 34648 KB Output is correct
22 Correct 0 ms 34648 KB Output is correct
23 Correct 0 ms 34648 KB Output is correct
24 Correct 0 ms 34648 KB Output is correct
25 Correct 0 ms 34648 KB Output is correct
26 Correct 0 ms 34648 KB Output is correct
27 Correct 2 ms 34648 KB Output is correct
28 Correct 2 ms 34648 KB Output is correct
29 Correct 0 ms 34648 KB Output is correct
30 Correct 0 ms 34648 KB Output is correct
31 Correct 2 ms 34648 KB Output is correct
32 Correct 0 ms 34648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 34648 KB Output is correct
2 Correct 0 ms 34648 KB Output is correct
3 Correct 0 ms 34648 KB Output is correct
4 Correct 0 ms 34648 KB Output is correct
5 Correct 0 ms 34648 KB Output is correct
6 Correct 0 ms 34648 KB Output is correct
7 Correct 0 ms 34648 KB Output is correct
8 Correct 0 ms 34648 KB Output is correct
9 Correct 0 ms 34648 KB Output is correct
10 Correct 0 ms 34648 KB Output is correct
11 Correct 0 ms 34648 KB Output is correct
12 Correct 0 ms 34648 KB Output is correct
13 Correct 0 ms 34648 KB Output is correct
14 Correct 0 ms 34648 KB Output is correct
15 Correct 0 ms 34648 KB Output is correct
16 Correct 0 ms 34648 KB Output is correct
17 Correct 0 ms 34648 KB Output is correct
18 Correct 0 ms 34648 KB Output is correct
19 Correct 0 ms 34648 KB Output is correct
20 Correct 0 ms 34648 KB Output is correct
21 Correct 0 ms 34648 KB Output is correct
22 Correct 0 ms 34648 KB Output is correct
23 Correct 0 ms 34648 KB Output is correct
24 Correct 0 ms 34648 KB Output is correct
25 Correct 0 ms 34648 KB Output is correct
26 Correct 0 ms 34648 KB Output is correct
27 Correct 0 ms 34648 KB Output is correct
28 Correct 0 ms 34648 KB Output is correct
29 Correct 0 ms 34648 KB Output is correct
30 Correct 0 ms 34648 KB Output is correct
31 Correct 0 ms 34648 KB Output is correct
32 Correct 0 ms 34648 KB Output is correct
33 Correct 0 ms 34648 KB Output is correct
34 Correct 0 ms 34648 KB Output is correct
35 Correct 0 ms 34648 KB Output is correct
36 Correct 0 ms 34648 KB Output is correct
37 Correct 0 ms 34648 KB Output is correct
38 Correct 0 ms 34648 KB Output is correct
39 Correct 0 ms 34648 KB Output is correct
40 Correct 0 ms 34648 KB Output is correct
41 Correct 0 ms 34648 KB Output is correct
42 Correct 0 ms 34648 KB Output is correct
43 Correct 0 ms 34648 KB Output is correct
44 Correct 0 ms 34648 KB Output is correct
45 Correct 0 ms 34648 KB Output is correct
46 Correct 0 ms 34648 KB Output is correct
47 Correct 0 ms 34648 KB Output is correct
48 Correct 0 ms 34648 KB Output is correct
49 Correct 0 ms 34648 KB Output is correct
50 Correct 0 ms 34648 KB Output is correct
51 Correct 2 ms 34648 KB Output is correct
52 Correct 0 ms 34648 KB Output is correct
53 Correct 2 ms 34648 KB Output is correct
54 Correct 0 ms 34648 KB Output is correct
55 Correct 0 ms 34648 KB Output is correct
56 Correct 0 ms 34648 KB Output is correct
57 Correct 0 ms 34648 KB Output is correct
58 Correct 0 ms 34648 KB Output is correct
59 Correct 2 ms 34648 KB Output is correct
60 Correct 0 ms 34648 KB Output is correct
61 Correct 2 ms 34648 KB Output is correct
62 Correct 0 ms 34648 KB Output is correct
63 Correct 0 ms 34648 KB Output is correct
64 Correct 11 ms 34648 KB Output is correct
65 Correct 0 ms 34648 KB Output is correct
66 Correct 0 ms 34648 KB Output is correct
67 Correct 3 ms 34648 KB Output is correct
68 Correct 15 ms 34648 KB Output is correct
69 Correct 27 ms 34648 KB Output is correct
70 Correct 30 ms 34648 KB Output is correct
71 Correct 0 ms 34648 KB Output is correct
72 Correct 28 ms 34648 KB Output is correct
73 Correct 19 ms 34648 KB Output is correct
74 Correct 20 ms 34648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 34648 KB Output is correct
2 Correct 0 ms 34648 KB Output is correct
3 Correct 0 ms 34648 KB Output is correct
4 Correct 0 ms 34648 KB Output is correct
5 Correct 0 ms 34648 KB Output is correct
6 Correct 0 ms 34648 KB Output is correct
7 Correct 0 ms 34648 KB Output is correct
8 Correct 0 ms 34648 KB Output is correct
9 Correct 0 ms 34648 KB Output is correct
10 Correct 0 ms 34648 KB Output is correct
11 Correct 0 ms 34648 KB Output is correct
12 Correct 0 ms 34648 KB Output is correct
13 Correct 0 ms 34648 KB Output is correct
14 Correct 0 ms 34648 KB Output is correct
15 Correct 0 ms 34648 KB Output is correct
16 Correct 0 ms 34648 KB Output is correct
17 Correct 0 ms 34648 KB Output is correct
18 Correct 0 ms 34648 KB Output is correct
19 Correct 1 ms 34648 KB Output is correct
20 Correct 0 ms 34648 KB Output is correct
21 Correct 0 ms 34648 KB Output is correct
22 Correct 0 ms 34648 KB Output is correct
23 Correct 0 ms 34648 KB Output is correct
24 Correct 0 ms 34648 KB Output is correct
25 Correct 0 ms 34648 KB Output is correct
26 Correct 0 ms 34648 KB Output is correct
27 Correct 0 ms 34648 KB Output is correct
28 Correct 0 ms 34648 KB Output is correct
29 Correct 0 ms 34648 KB Output is correct
30 Correct 0 ms 34648 KB Output is correct
31 Correct 0 ms 34648 KB Output is correct
32 Correct 0 ms 34648 KB Output is correct
33 Correct 0 ms 34648 KB Output is correct
34 Correct 0 ms 34648 KB Output is correct
35 Correct 0 ms 34648 KB Output is correct
36 Correct 0 ms 34648 KB Output is correct
37 Correct 0 ms 34648 KB Output is correct
38 Correct 0 ms 34648 KB Output is correct
39 Correct 0 ms 34648 KB Output is correct
40 Correct 0 ms 34648 KB Output is correct
41 Correct 0 ms 34648 KB Output is correct
42 Correct 0 ms 34648 KB Output is correct
43 Correct 0 ms 34648 KB Output is correct
44 Correct 0 ms 34648 KB Output is correct
45 Correct 0 ms 34648 KB Output is correct
46 Correct 0 ms 34648 KB Output is correct
47 Correct 2 ms 34648 KB Output is correct
48 Correct 0 ms 34648 KB Output is correct
49 Correct 0 ms 34648 KB Output is correct
50 Correct 0 ms 34648 KB Output is correct
51 Correct 2 ms 34648 KB Output is correct
52 Correct 28 ms 34648 KB Output is correct
53 Correct 51 ms 34648 KB Output is correct
54 Correct 95 ms 34648 KB Output is correct
55 Correct 88 ms 34648 KB Output is correct
56 Correct 361 ms 34648 KB Output is correct
57 Correct 358 ms 34648 KB Output is correct
58 Correct 339 ms 34648 KB Output is correct
59 Correct 320 ms 34648 KB Output is correct
60 Correct 327 ms 34648 KB Output is correct
61 Correct 2 ms 34648 KB Output is correct
62 Correct 50 ms 34648 KB Output is correct
63 Correct 90 ms 34648 KB Output is correct
64 Correct 87 ms 34648 KB Output is correct
65 Correct 168 ms 34648 KB Output is correct
66 Correct 275 ms 34648 KB Output is correct
67 Correct 337 ms 34648 KB Output is correct
68 Correct 371 ms 34648 KB Output is correct
69 Correct 353 ms 34648 KB Output is correct