Submission #60516

# Submission time Handle Problem Language Result Execution time Memory
60516 2018-07-24T09:34:36 Z Flugan42 Bali Sculptures (APIO15_sculpture) C++14
100 / 100
125 ms 984 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef long double lld;
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define per(i,a,b) for(ll i = a; i >= b; i--)
#define sz(x) (ll)(x).size()
#define all(x) x.begin(),x.end()
#define inf 1000000000000000000

ll n,a,b,ans;
vi y;

string binary(ll x){
  string s = "";
  while(x>0){
    if (x%2) s += '1';
    else s += '0';
    x /= 2;
  }
  reverse(all(s));
  return s;
}

bool solve(ll x){
  //cout << binary(((1LL<<50)-1LL)^x) << endl;
  if (a == 1){
    vi dp; dp.assign(n+1,inf); dp[0] = 0;
    rep(i,1,n+1){
      ll cur = 0;
      per(j,i-1,0){
        cur += y[j];
        //cout << cur << " " << (cur&(((1LL<<50)-1LL)^x)) << " " << j << " " << dp[j] << endl;
        if ((cur&(((1LL<<60LL)-1LL)^x)) == 0) dp[i] = min(dp[i],dp[j]+1);
      }
    }
    //rep(i,0,n) cout << dp[i] << " ";
    //cout << endl;
    //cout << x << " " << dp[n] << endl;
    if (dp[n] <= b) return 1;
    return 0;
  } else {
    vector<vi> dp;
    vi _; _.assign(n+1,0);
    dp.assign(n+1,_);
    dp[0][0] = 1;
    rep(i,1,n+1) rep(j,1,n+1){
      ll cur = 0;
      per(k,j-1,0){
        cur += y[k];
        if ((cur&(((1LL<<60LL)-1LL)^x)) == 0) {
          if (dp[i-1][k]) dp[i][j] = 1;
        }
      }
    }
    rep(i,a,b+1) if (dp[i][n]) return 1;
    return 0;
  }
}

int main(){
  cin >> n >> a >> b; y.assign(n,0);
  rep(i,0,n) cin >> y[i];
  ans = 0;
  per(i,40,0) if (!solve(ans+(1LL<<i)-1LL)) ans += (1LL<<i);
  cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 4 ms 396 KB Output is correct
4 Correct 3 ms 476 KB Output is correct
5 Correct 3 ms 476 KB Output is correct
6 Correct 2 ms 476 KB Output is correct
7 Correct 2 ms 476 KB Output is correct
8 Correct 3 ms 484 KB Output is correct
9 Correct 2 ms 544 KB Output is correct
10 Correct 3 ms 544 KB Output is correct
11 Correct 3 ms 560 KB Output is correct
12 Correct 3 ms 580 KB Output is correct
13 Correct 2 ms 580 KB Output is correct
14 Correct 3 ms 580 KB Output is correct
15 Correct 3 ms 580 KB Output is correct
16 Correct 3 ms 580 KB Output is correct
17 Correct 3 ms 580 KB Output is correct
18 Correct 3 ms 580 KB Output is correct
19 Correct 3 ms 580 KB Output is correct
20 Correct 3 ms 580 KB Output is correct
21 Correct 3 ms 580 KB Output is correct
22 Correct 4 ms 580 KB Output is correct
23 Correct 3 ms 580 KB Output is correct
24 Correct 4 ms 608 KB Output is correct
25 Correct 4 ms 608 KB Output is correct
26 Correct 3 ms 608 KB Output is correct
27 Correct 2 ms 608 KB Output is correct
28 Correct 4 ms 608 KB Output is correct
29 Correct 3 ms 608 KB Output is correct
30 Correct 2 ms 608 KB Output is correct
31 Correct 3 ms 608 KB Output is correct
32 Correct 2 ms 608 KB Output is correct
33 Correct 2 ms 608 KB Output is correct
34 Correct 3 ms 608 KB Output is correct
35 Correct 2 ms 608 KB Output is correct
36 Correct 3 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 608 KB Output is correct
2 Correct 3 ms 608 KB Output is correct
3 Correct 3 ms 608 KB Output is correct
4 Correct 3 ms 608 KB Output is correct
5 Correct 2 ms 608 KB Output is correct
6 Correct 3 ms 608 KB Output is correct
7 Correct 2 ms 620 KB Output is correct
8 Correct 3 ms 620 KB Output is correct
9 Correct 3 ms 620 KB Output is correct
10 Correct 3 ms 620 KB Output is correct
11 Correct 3 ms 620 KB Output is correct
12 Correct 3 ms 620 KB Output is correct
13 Correct 2 ms 620 KB Output is correct
14 Correct 3 ms 620 KB Output is correct
15 Correct 2 ms 620 KB Output is correct
16 Correct 2 ms 620 KB Output is correct
17 Correct 4 ms 620 KB Output is correct
18 Correct 2 ms 620 KB Output is correct
19 Correct 3 ms 620 KB Output is correct
20 Correct 3 ms 620 KB Output is correct
21 Correct 3 ms 620 KB Output is correct
22 Correct 3 ms 620 KB Output is correct
23 Correct 4 ms 620 KB Output is correct
24 Correct 3 ms 620 KB Output is correct
25 Correct 3 ms 620 KB Output is correct
26 Correct 3 ms 620 KB Output is correct
27 Correct 3 ms 620 KB Output is correct
28 Correct 3 ms 620 KB Output is correct
29 Correct 4 ms 620 KB Output is correct
30 Correct 3 ms 620 KB Output is correct
31 Correct 3 ms 620 KB Output is correct
32 Correct 3 ms 620 KB Output is correct
33 Correct 3 ms 620 KB Output is correct
34 Correct 1 ms 620 KB Output is correct
35 Correct 3 ms 620 KB Output is correct
36 Correct 3 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 620 KB Output is correct
2 Correct 3 ms 620 KB Output is correct
3 Correct 3 ms 620 KB Output is correct
4 Correct 3 ms 620 KB Output is correct
5 Correct 3 ms 620 KB Output is correct
6 Correct 3 ms 620 KB Output is correct
7 Correct 3 ms 620 KB Output is correct
8 Correct 3 ms 620 KB Output is correct
9 Correct 3 ms 620 KB Output is correct
10 Correct 3 ms 620 KB Output is correct
11 Correct 3 ms 620 KB Output is correct
12 Correct 3 ms 620 KB Output is correct
13 Correct 3 ms 620 KB Output is correct
14 Correct 3 ms 620 KB Output is correct
15 Correct 4 ms 620 KB Output is correct
16 Correct 3 ms 620 KB Output is correct
17 Correct 3 ms 636 KB Output is correct
18 Correct 3 ms 636 KB Output is correct
19 Correct 3 ms 636 KB Output is correct
20 Correct 5 ms 636 KB Output is correct
21 Correct 3 ms 636 KB Output is correct
22 Correct 3 ms 636 KB Output is correct
23 Correct 3 ms 636 KB Output is correct
24 Correct 2 ms 636 KB Output is correct
25 Correct 3 ms 636 KB Output is correct
26 Correct 2 ms 636 KB Output is correct
27 Correct 4 ms 636 KB Output is correct
28 Correct 4 ms 636 KB Output is correct
29 Correct 4 ms 636 KB Output is correct
30 Correct 3 ms 636 KB Output is correct
31 Correct 3 ms 636 KB Output is correct
32 Correct 3 ms 636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 636 KB Output is correct
2 Correct 2 ms 636 KB Output is correct
3 Correct 4 ms 636 KB Output is correct
4 Correct 3 ms 636 KB Output is correct
5 Correct 3 ms 636 KB Output is correct
6 Correct 3 ms 636 KB Output is correct
7 Correct 3 ms 636 KB Output is correct
8 Correct 3 ms 636 KB Output is correct
9 Correct 3 ms 636 KB Output is correct
10 Correct 2 ms 636 KB Output is correct
11 Correct 3 ms 636 KB Output is correct
12 Correct 3 ms 636 KB Output is correct
13 Correct 3 ms 636 KB Output is correct
14 Correct 3 ms 636 KB Output is correct
15 Correct 3 ms 636 KB Output is correct
16 Correct 2 ms 636 KB Output is correct
17 Correct 4 ms 636 KB Output is correct
18 Correct 3 ms 636 KB Output is correct
19 Correct 3 ms 636 KB Output is correct
20 Correct 3 ms 636 KB Output is correct
21 Correct 4 ms 636 KB Output is correct
22 Correct 2 ms 636 KB Output is correct
23 Correct 3 ms 636 KB Output is correct
24 Correct 3 ms 636 KB Output is correct
25 Correct 3 ms 636 KB Output is correct
26 Correct 3 ms 636 KB Output is correct
27 Correct 2 ms 636 KB Output is correct
28 Correct 2 ms 636 KB Output is correct
29 Correct 3 ms 636 KB Output is correct
30 Correct 3 ms 636 KB Output is correct
31 Correct 3 ms 636 KB Output is correct
32 Correct 4 ms 636 KB Output is correct
33 Correct 3 ms 636 KB Output is correct
34 Correct 3 ms 636 KB Output is correct
35 Correct 3 ms 636 KB Output is correct
36 Correct 3 ms 636 KB Output is correct
37 Correct 3 ms 636 KB Output is correct
38 Correct 3 ms 636 KB Output is correct
39 Correct 3 ms 636 KB Output is correct
40 Correct 3 ms 636 KB Output is correct
41 Correct 2 ms 636 KB Output is correct
42 Correct 3 ms 636 KB Output is correct
43 Correct 2 ms 636 KB Output is correct
44 Correct 3 ms 636 KB Output is correct
45 Correct 2 ms 636 KB Output is correct
46 Correct 2 ms 636 KB Output is correct
47 Correct 2 ms 636 KB Output is correct
48 Correct 3 ms 636 KB Output is correct
49 Correct 3 ms 636 KB Output is correct
50 Correct 4 ms 636 KB Output is correct
51 Correct 4 ms 636 KB Output is correct
52 Correct 4 ms 636 KB Output is correct
53 Correct 3 ms 636 KB Output is correct
54 Correct 3 ms 636 KB Output is correct
55 Correct 3 ms 636 KB Output is correct
56 Correct 4 ms 636 KB Output is correct
57 Correct 2 ms 636 KB Output is correct
58 Correct 3 ms 636 KB Output is correct
59 Correct 3 ms 636 KB Output is correct
60 Correct 3 ms 636 KB Output is correct
61 Correct 3 ms 636 KB Output is correct
62 Correct 3 ms 636 KB Output is correct
63 Correct 3 ms 636 KB Output is correct
64 Correct 35 ms 644 KB Output is correct
65 Correct 8 ms 648 KB Output is correct
66 Correct 16 ms 652 KB Output is correct
67 Correct 19 ms 656 KB Output is correct
68 Correct 29 ms 660 KB Output is correct
69 Correct 37 ms 736 KB Output is correct
70 Correct 30 ms 736 KB Output is correct
71 Correct 33 ms 736 KB Output is correct
72 Correct 43 ms 736 KB Output is correct
73 Correct 42 ms 736 KB Output is correct
74 Correct 38 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 736 KB Output is correct
2 Correct 3 ms 736 KB Output is correct
3 Correct 2 ms 736 KB Output is correct
4 Correct 3 ms 736 KB Output is correct
5 Correct 3 ms 736 KB Output is correct
6 Correct 3 ms 736 KB Output is correct
7 Correct 3 ms 736 KB Output is correct
8 Correct 2 ms 736 KB Output is correct
9 Correct 2 ms 736 KB Output is correct
10 Correct 3 ms 736 KB Output is correct
11 Correct 3 ms 736 KB Output is correct
12 Correct 2 ms 736 KB Output is correct
13 Correct 4 ms 736 KB Output is correct
14 Correct 2 ms 736 KB Output is correct
15 Correct 3 ms 736 KB Output is correct
16 Correct 3 ms 736 KB Output is correct
17 Correct 2 ms 736 KB Output is correct
18 Correct 2 ms 736 KB Output is correct
19 Correct 3 ms 736 KB Output is correct
20 Correct 3 ms 736 KB Output is correct
21 Correct 3 ms 736 KB Output is correct
22 Correct 2 ms 736 KB Output is correct
23 Correct 3 ms 736 KB Output is correct
24 Correct 2 ms 736 KB Output is correct
25 Correct 3 ms 736 KB Output is correct
26 Correct 3 ms 736 KB Output is correct
27 Correct 3 ms 736 KB Output is correct
28 Correct 2 ms 736 KB Output is correct
29 Correct 3 ms 736 KB Output is correct
30 Correct 4 ms 736 KB Output is correct
31 Correct 3 ms 736 KB Output is correct
32 Correct 3 ms 736 KB Output is correct
33 Correct 4 ms 736 KB Output is correct
34 Correct 3 ms 736 KB Output is correct
35 Correct 2 ms 736 KB Output is correct
36 Correct 2 ms 736 KB Output is correct
37 Correct 3 ms 736 KB Output is correct
38 Correct 3 ms 736 KB Output is correct
39 Correct 3 ms 736 KB Output is correct
40 Correct 3 ms 736 KB Output is correct
41 Correct 3 ms 736 KB Output is correct
42 Correct 4 ms 736 KB Output is correct
43 Correct 3 ms 736 KB Output is correct
44 Correct 2 ms 736 KB Output is correct
45 Correct 3 ms 736 KB Output is correct
46 Correct 4 ms 736 KB Output is correct
47 Correct 3 ms 736 KB Output is correct
48 Correct 4 ms 736 KB Output is correct
49 Correct 4 ms 736 KB Output is correct
50 Correct 4 ms 736 KB Output is correct
51 Correct 4 ms 736 KB Output is correct
52 Correct 13 ms 736 KB Output is correct
53 Correct 18 ms 736 KB Output is correct
54 Correct 32 ms 736 KB Output is correct
55 Correct 31 ms 736 KB Output is correct
56 Correct 119 ms 736 KB Output is correct
57 Correct 101 ms 752 KB Output is correct
58 Correct 105 ms 772 KB Output is correct
59 Correct 105 ms 792 KB Output is correct
60 Correct 125 ms 816 KB Output is correct
61 Correct 4 ms 816 KB Output is correct
62 Correct 21 ms 844 KB Output is correct
63 Correct 35 ms 864 KB Output is correct
64 Correct 33 ms 864 KB Output is correct
65 Correct 60 ms 900 KB Output is correct
66 Correct 81 ms 900 KB Output is correct
67 Correct 105 ms 912 KB Output is correct
68 Correct 108 ms 932 KB Output is correct
69 Correct 113 ms 984 KB Output is correct