Submission #25015

# Submission time Handle Problem Language Result Execution time Memory
25015 2017-06-20T04:02:54 Z 시제연(#1054) Bali Sculptures (APIO15_sculpture) C++
100 / 100
76 ms 23324 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, a, b;
ll arr[2100];
ll sum[2100];
vector<int> loc[2100];
vector<int> tloc[2100];
int bd[2100]; bool sd[110][110];

bool dodyn() {
    int i, j, k;
    if (a==1) {
        bd[0] = 0;
        for (i=1;i<=n;i++) bd[i] = 5000;
        for (i=1;i<=n;i++) {
            for (j=0;j<tloc[i].size();j++) {
                bd[i] = min(bd[i],bd[tloc[i][j]]+1);
            }
        }
        return bd[n]<=b;
    }
    sd[0][0] = true;
    for (j=1;j<=n;j++) {
        for (i=1;i<=n;i++) {
            sd[i][j] = false;
            for (k=0;k<tloc[i].size();k++) {
                sd[i][j] |= sd[tloc[i][k]][j-1];
            }
        }
    }
    for (j=a;j<=b;j++) if (sd[n][j]) return true;
    return false;
}

void georeum(int bit) {
    int i, j;
    for (i=1;i<=n;i++) {
        tloc[i].clear();
        for (j=0;j<loc[i].size();j++) {
            if (~((sum[i]-sum[loc[i][j]])>>bit)&1) tloc[i].push_back(loc[i][j]);
        }
    }
}

void mov() {
    int i;
    for (i=1;i<=n;i++) loc[i].assign(tloc[i].begin(),tloc[i].end());
}

int main() {
    int i, j, bit;
    ll res = 0;

    scanf("%d%d%d",&n,&a,&b);
    for (i=1;i<=n;i++) scanf("%lld",&arr[i]);
    for (i=1;i<=n;i++) sum[i] = sum[i-1]+arr[i];
    for (i=1;i<=n;i++) for (j=0;j<i;j++) loc[i].push_back(j);
    for (bit=40;bit>=0;bit--) {
        georeum(bit);
        if (dodyn()) mov();
        else res += (1LL<<bit);
    }
    printf("%lld\n",res);

    return 0;
}

Compilation message

sculpture.cpp: In function 'bool dodyn()':
sculpture.cpp:20:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (j=0;j<tloc[i].size();j++) {
                       ^
sculpture.cpp:30:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (k=0;k<tloc[i].size();k++) {
                       ^
sculpture.cpp: In function 'void georeum(int)':
sculpture.cpp:43:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (j=0;j<loc[i].size();j++) {
                   ^
sculpture.cpp: In function 'int main()':
sculpture.cpp:58:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d",&n,&a,&b);
                             ^
sculpture.cpp:59:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for (i=1;i<=n;i++) scanf("%lld",&arr[i]);
                                             ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2172 KB Output is correct
2 Correct 0 ms 2172 KB Output is correct
3 Correct 0 ms 2172 KB Output is correct
4 Correct 0 ms 2172 KB Output is correct
5 Correct 0 ms 2172 KB Output is correct
6 Correct 0 ms 2172 KB Output is correct
7 Correct 0 ms 2172 KB Output is correct
8 Correct 0 ms 2172 KB Output is correct
9 Correct 0 ms 2172 KB Output is correct
10 Correct 0 ms 2172 KB Output is correct
11 Correct 0 ms 2172 KB Output is correct
12 Correct 0 ms 2172 KB Output is correct
13 Correct 0 ms 2172 KB Output is correct
14 Correct 0 ms 2172 KB Output is correct
15 Correct 0 ms 2172 KB Output is correct
16 Correct 0 ms 2172 KB Output is correct
17 Correct 0 ms 2172 KB Output is correct
18 Correct 0 ms 2172 KB Output is correct
19 Correct 0 ms 2172 KB Output is correct
20 Correct 0 ms 2172 KB Output is correct
21 Correct 0 ms 2172 KB Output is correct
22 Correct 0 ms 2172 KB Output is correct
23 Correct 0 ms 2172 KB Output is correct
24 Correct 0 ms 2172 KB Output is correct
25 Correct 0 ms 2172 KB Output is correct
26 Correct 0 ms 2172 KB Output is correct
27 Correct 0 ms 2172 KB Output is correct
28 Correct 0 ms 2172 KB Output is correct
29 Correct 0 ms 2172 KB Output is correct
30 Correct 0 ms 2172 KB Output is correct
31 Correct 0 ms 2172 KB Output is correct
32 Correct 0 ms 2172 KB Output is correct
33 Correct 0 ms 2172 KB Output is correct
34 Correct 0 ms 2172 KB Output is correct
35 Correct 0 ms 2172 KB Output is correct
36 Correct 0 ms 2172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2172 KB Output is correct
2 Correct 0 ms 2172 KB Output is correct
3 Correct 0 ms 2172 KB Output is correct
4 Correct 0 ms 2172 KB Output is correct
5 Correct 0 ms 2172 KB Output is correct
6 Correct 0 ms 2172 KB Output is correct
7 Correct 0 ms 2172 KB Output is correct
8 Correct 0 ms 2172 KB Output is correct
9 Correct 0 ms 2172 KB Output is correct
10 Correct 0 ms 2172 KB Output is correct
11 Correct 0 ms 2172 KB Output is correct
12 Correct 0 ms 2172 KB Output is correct
13 Correct 0 ms 2172 KB Output is correct
14 Correct 0 ms 2172 KB Output is correct
15 Correct 0 ms 2172 KB Output is correct
16 Correct 0 ms 2172 KB Output is correct
17 Correct 0 ms 2172 KB Output is correct
18 Correct 0 ms 2172 KB Output is correct
19 Correct 0 ms 2172 KB Output is correct
20 Correct 0 ms 2172 KB Output is correct
21 Correct 0 ms 2172 KB Output is correct
22 Correct 0 ms 2172 KB Output is correct
23 Correct 0 ms 2172 KB Output is correct
24 Correct 0 ms 2172 KB Output is correct
25 Correct 0 ms 2172 KB Output is correct
26 Correct 0 ms 2172 KB Output is correct
27 Correct 0 ms 2172 KB Output is correct
28 Correct 0 ms 2172 KB Output is correct
29 Correct 0 ms 2172 KB Output is correct
30 Correct 0 ms 2172 KB Output is correct
31 Correct 0 ms 2172 KB Output is correct
32 Correct 0 ms 2172 KB Output is correct
33 Correct 0 ms 2172 KB Output is correct
34 Correct 0 ms 2172 KB Output is correct
35 Correct 0 ms 2172 KB Output is correct
36 Correct 0 ms 2172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2172 KB Output is correct
2 Correct 0 ms 2172 KB Output is correct
3 Correct 0 ms 2172 KB Output is correct
4 Correct 0 ms 2172 KB Output is correct
5 Correct 0 ms 2172 KB Output is correct
6 Correct 0 ms 2172 KB Output is correct
7 Correct 0 ms 2172 KB Output is correct
8 Correct 0 ms 2172 KB Output is correct
9 Correct 0 ms 2172 KB Output is correct
10 Correct 0 ms 2172 KB Output is correct
11 Correct 0 ms 2172 KB Output is correct
12 Correct 0 ms 2172 KB Output is correct
13 Correct 0 ms 2172 KB Output is correct
14 Correct 0 ms 2172 KB Output is correct
15 Correct 0 ms 2172 KB Output is correct
16 Correct 0 ms 2172 KB Output is correct
17 Correct 0 ms 2172 KB Output is correct
18 Correct 0 ms 2172 KB Output is correct
19 Correct 0 ms 2172 KB Output is correct
20 Correct 0 ms 2172 KB Output is correct
21 Correct 0 ms 2172 KB Output is correct
22 Correct 0 ms 2172 KB Output is correct
23 Correct 0 ms 2172 KB Output is correct
24 Correct 0 ms 2172 KB Output is correct
25 Correct 0 ms 2172 KB Output is correct
26 Correct 0 ms 2172 KB Output is correct
27 Correct 0 ms 2304 KB Output is correct
28 Correct 0 ms 2304 KB Output is correct
29 Correct 0 ms 2304 KB Output is correct
30 Correct 0 ms 2304 KB Output is correct
31 Correct 0 ms 2304 KB Output is correct
32 Correct 0 ms 2304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2172 KB Output is correct
2 Correct 0 ms 2172 KB Output is correct
3 Correct 0 ms 2172 KB Output is correct
4 Correct 0 ms 2172 KB Output is correct
5 Correct 0 ms 2172 KB Output is correct
6 Correct 0 ms 2172 KB Output is correct
7 Correct 0 ms 2172 KB Output is correct
8 Correct 0 ms 2172 KB Output is correct
9 Correct 0 ms 2172 KB Output is correct
10 Correct 0 ms 2172 KB Output is correct
11 Correct 0 ms 2172 KB Output is correct
12 Correct 0 ms 2172 KB Output is correct
13 Correct 0 ms 2172 KB Output is correct
14 Correct 0 ms 2172 KB Output is correct
15 Correct 0 ms 2172 KB Output is correct
16 Correct 0 ms 2172 KB Output is correct
17 Correct 0 ms 2172 KB Output is correct
18 Correct 0 ms 2172 KB Output is correct
19 Correct 0 ms 2172 KB Output is correct
20 Correct 0 ms 2172 KB Output is correct
21 Correct 0 ms 2172 KB Output is correct
22 Correct 0 ms 2172 KB Output is correct
23 Correct 0 ms 2172 KB Output is correct
24 Correct 0 ms 2172 KB Output is correct
25 Correct 0 ms 2172 KB Output is correct
26 Correct 0 ms 2172 KB Output is correct
27 Correct 0 ms 2172 KB Output is correct
28 Correct 0 ms 2172 KB Output is correct
29 Correct 0 ms 2172 KB Output is correct
30 Correct 0 ms 2172 KB Output is correct
31 Correct 0 ms 2172 KB Output is correct
32 Correct 0 ms 2172 KB Output is correct
33 Correct 0 ms 2172 KB Output is correct
34 Correct 0 ms 2172 KB Output is correct
35 Correct 0 ms 2172 KB Output is correct
36 Correct 0 ms 2172 KB Output is correct
37 Correct 0 ms 2172 KB Output is correct
38 Correct 0 ms 2172 KB Output is correct
39 Correct 0 ms 2172 KB Output is correct
40 Correct 0 ms 2172 KB Output is correct
41 Correct 0 ms 2172 KB Output is correct
42 Correct 0 ms 2172 KB Output is correct
43 Correct 0 ms 2172 KB Output is correct
44 Correct 0 ms 2172 KB Output is correct
45 Correct 0 ms 2172 KB Output is correct
46 Correct 0 ms 2172 KB Output is correct
47 Correct 0 ms 2172 KB Output is correct
48 Correct 0 ms 2172 KB Output is correct
49 Correct 0 ms 2172 KB Output is correct
50 Correct 0 ms 2304 KB Output is correct
51 Correct 0 ms 2304 KB Output is correct
52 Correct 0 ms 2304 KB Output is correct
53 Correct 0 ms 2304 KB Output is correct
54 Correct 0 ms 2304 KB Output is correct
55 Correct 0 ms 2304 KB Output is correct
56 Correct 0 ms 2172 KB Output is correct
57 Correct 0 ms 2172 KB Output is correct
58 Correct 0 ms 2304 KB Output is correct
59 Correct 0 ms 2304 KB Output is correct
60 Correct 0 ms 2304 KB Output is correct
61 Correct 0 ms 2304 KB Output is correct
62 Correct 0 ms 2304 KB Output is correct
63 Correct 0 ms 2304 KB Output is correct
64 Correct 16 ms 2304 KB Output is correct
65 Correct 0 ms 2172 KB Output is correct
66 Correct 0 ms 2172 KB Output is correct
67 Correct 3 ms 2172 KB Output is correct
68 Correct 3 ms 2304 KB Output is correct
69 Correct 3 ms 2304 KB Output is correct
70 Correct 3 ms 2304 KB Output is correct
71 Correct 6 ms 2304 KB Output is correct
72 Correct 6 ms 2304 KB Output is correct
73 Correct 6 ms 2304 KB Output is correct
74 Correct 9 ms 2304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2172 KB Output is correct
2 Correct 0 ms 2172 KB Output is correct
3 Correct 0 ms 2172 KB Output is correct
4 Correct 0 ms 2172 KB Output is correct
5 Correct 0 ms 2172 KB Output is correct
6 Correct 0 ms 2172 KB Output is correct
7 Correct 0 ms 2172 KB Output is correct
8 Correct 0 ms 2172 KB Output is correct
9 Correct 0 ms 2172 KB Output is correct
10 Correct 0 ms 2172 KB Output is correct
11 Correct 0 ms 2172 KB Output is correct
12 Correct 0 ms 2172 KB Output is correct
13 Correct 0 ms 2172 KB Output is correct
14 Correct 0 ms 2172 KB Output is correct
15 Correct 0 ms 2172 KB Output is correct
16 Correct 0 ms 2172 KB Output is correct
17 Correct 0 ms 2172 KB Output is correct
18 Correct 0 ms 2172 KB Output is correct
19 Correct 0 ms 2172 KB Output is correct
20 Correct 0 ms 2172 KB Output is correct
21 Correct 0 ms 2172 KB Output is correct
22 Correct 0 ms 2172 KB Output is correct
23 Correct 0 ms 2172 KB Output is correct
24 Correct 0 ms 2172 KB Output is correct
25 Correct 0 ms 2172 KB Output is correct
26 Correct 0 ms 2172 KB Output is correct
27 Correct 0 ms 2172 KB Output is correct
28 Correct 0 ms 2172 KB Output is correct
29 Correct 0 ms 2172 KB Output is correct
30 Correct 0 ms 2172 KB Output is correct
31 Correct 0 ms 2172 KB Output is correct
32 Correct 0 ms 2172 KB Output is correct
33 Correct 0 ms 2172 KB Output is correct
34 Correct 0 ms 2172 KB Output is correct
35 Correct 0 ms 2172 KB Output is correct
36 Correct 0 ms 2172 KB Output is correct
37 Correct 0 ms 2304 KB Output is correct
38 Correct 0 ms 2304 KB Output is correct
39 Correct 0 ms 2304 KB Output is correct
40 Correct 0 ms 2304 KB Output is correct
41 Correct 0 ms 2304 KB Output is correct
42 Correct 0 ms 2304 KB Output is correct
43 Correct 0 ms 2172 KB Output is correct
44 Correct 0 ms 2172 KB Output is correct
45 Correct 0 ms 2304 KB Output is correct
46 Correct 0 ms 2304 KB Output is correct
47 Correct 0 ms 2304 KB Output is correct
48 Correct 0 ms 2304 KB Output is correct
49 Correct 0 ms 2304 KB Output is correct
50 Correct 0 ms 2304 KB Output is correct
51 Correct 0 ms 2304 KB Output is correct
52 Correct 6 ms 4020 KB Output is correct
53 Correct 9 ms 5472 KB Output is correct
54 Correct 19 ms 7452 KB Output is correct
55 Correct 16 ms 7452 KB Output is correct
56 Correct 46 ms 23324 KB Output is correct
57 Correct 66 ms 23324 KB Output is correct
58 Correct 43 ms 23324 KB Output is correct
59 Correct 53 ms 23324 KB Output is correct
60 Correct 63 ms 23324 KB Output is correct
61 Correct 0 ms 2304 KB Output is correct
62 Correct 6 ms 5472 KB Output is correct
63 Correct 19 ms 7452 KB Output is correct
64 Correct 23 ms 7452 KB Output is correct
65 Correct 36 ms 13824 KB Output is correct
66 Correct 39 ms 19252 KB Output is correct
67 Correct 76 ms 23324 KB Output is correct
68 Correct 73 ms 23324 KB Output is correct
69 Correct 49 ms 23324 KB Output is correct