Submission #168625

# Submission time Handle Problem Language Result Execution time Memory
168625 2019-12-14T15:42:38 Z Milki Bali Sculptures (APIO15_sculpture) C++14
71 / 100
1000 ms 32008 KB
#include<bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl

typedef long long ll;
typedef pair<int, int> point;

const int mod = 1e9 + 7;

int add(int x, int y) {x += y; if(x >= mod) return x - mod; return x;}
int sub(int x, int y) {x -= y; if(x < 0) return x + mod; return x;}
int mul(int x, int y) {return (ll) x * y % mod;}

const int MAXN = 2e3 + 5;

ll n, a, b, x[MAXN], prefix[MAXN], dp[MAXN][MAXN];

int rek(int pos, int num, ll forbidden){
  if(pos < 0){
    if(num >= a && num <= b)
      return 1;
    else
      return 0;
  }
  if(dp[pos][num] != -1)
    return dp[pos][num];

  int ret = 0;
  ll sum = 0;
  for(int i = pos; i >= 0; --i){
    sum += x[i];
    if((sum & forbidden) == 0)
      ret |= rek(i - 1, num + 1, forbidden);
    if(ret)
      return dp[pos][num] = ret;
  }

  return dp[pos][num] = ret;
}

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);

  cin >> n >> a >> b;
  REP(i, n)
    cin >> x[i];

  ll forbidden = 0, sol = 0;
  for(int i = 60; i >= 0; --i){
    memset(dp, -1, sizeof(dp));
    forbidden |= (1LL << i);
    if(!rek(n - 1, 0, forbidden)){
      forbidden ^= (1LL << i);
      sol |= (1LL << i);
    }
  }
  cout << sol;
}
# Verdict Execution time Memory Grader output
1 Correct 239 ms 31864 KB Output is correct
2 Correct 239 ms 31884 KB Output is correct
3 Correct 342 ms 31864 KB Output is correct
4 Correct 245 ms 31864 KB Output is correct
5 Correct 237 ms 31916 KB Output is correct
6 Correct 266 ms 31856 KB Output is correct
7 Correct 244 ms 31864 KB Output is correct
8 Correct 248 ms 31864 KB Output is correct
9 Correct 319 ms 31864 KB Output is correct
10 Correct 291 ms 31864 KB Output is correct
11 Correct 263 ms 31864 KB Output is correct
12 Correct 268 ms 31864 KB Output is correct
13 Correct 304 ms 31736 KB Output is correct
14 Correct 279 ms 31864 KB Output is correct
15 Correct 269 ms 31736 KB Output is correct
16 Correct 338 ms 31864 KB Output is correct
17 Correct 309 ms 31992 KB Output is correct
18 Correct 340 ms 31864 KB Output is correct
19 Correct 323 ms 31856 KB Output is correct
20 Correct 321 ms 31864 KB Output is correct
21 Correct 267 ms 31864 KB Output is correct
22 Correct 298 ms 31864 KB Output is correct
23 Correct 270 ms 31864 KB Output is correct
24 Correct 254 ms 31736 KB Output is correct
25 Correct 248 ms 31864 KB Output is correct
26 Correct 319 ms 31864 KB Output is correct
27 Correct 243 ms 31740 KB Output is correct
28 Correct 233 ms 31856 KB Output is correct
29 Correct 256 ms 31888 KB Output is correct
30 Correct 268 ms 31736 KB Output is correct
31 Correct 274 ms 31940 KB Output is correct
32 Correct 336 ms 31740 KB Output is correct
33 Correct 284 ms 31736 KB Output is correct
34 Correct 282 ms 31920 KB Output is correct
35 Correct 346 ms 31884 KB Output is correct
36 Correct 269 ms 31864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 317 ms 31904 KB Output is correct
2 Correct 320 ms 31736 KB Output is correct
3 Correct 320 ms 31996 KB Output is correct
4 Correct 304 ms 31888 KB Output is correct
5 Correct 270 ms 31736 KB Output is correct
6 Correct 335 ms 31856 KB Output is correct
7 Correct 311 ms 31740 KB Output is correct
8 Correct 280 ms 31736 KB Output is correct
9 Correct 303 ms 31864 KB Output is correct
10 Correct 303 ms 31864 KB Output is correct
11 Correct 301 ms 31852 KB Output is correct
12 Correct 289 ms 31864 KB Output is correct
13 Correct 291 ms 31864 KB Output is correct
14 Correct 303 ms 31864 KB Output is correct
15 Correct 335 ms 31864 KB Output is correct
16 Correct 282 ms 31864 KB Output is correct
17 Correct 302 ms 31860 KB Output is correct
18 Correct 301 ms 31736 KB Output is correct
19 Correct 280 ms 31864 KB Output is correct
20 Correct 311 ms 31736 KB Output is correct
21 Correct 335 ms 31736 KB Output is correct
22 Correct 344 ms 31864 KB Output is correct
23 Correct 357 ms 31864 KB Output is correct
24 Correct 326 ms 31736 KB Output is correct
25 Correct 328 ms 31736 KB Output is correct
26 Correct 340 ms 31864 KB Output is correct
27 Correct 342 ms 31964 KB Output is correct
28 Correct 343 ms 31864 KB Output is correct
29 Correct 340 ms 31864 KB Output is correct
30 Correct 362 ms 31864 KB Output is correct
31 Correct 355 ms 31864 KB Output is correct
32 Correct 355 ms 31864 KB Output is correct
33 Correct 293 ms 31736 KB Output is correct
34 Correct 419 ms 31864 KB Output is correct
35 Correct 364 ms 31864 KB Output is correct
36 Correct 336 ms 31884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 322 ms 31864 KB Output is correct
2 Correct 340 ms 31888 KB Output is correct
3 Correct 273 ms 31864 KB Output is correct
4 Correct 281 ms 31864 KB Output is correct
5 Correct 266 ms 31864 KB Output is correct
6 Correct 256 ms 31740 KB Output is correct
7 Correct 290 ms 31736 KB Output is correct
8 Correct 270 ms 31864 KB Output is correct
9 Correct 302 ms 31852 KB Output is correct
10 Correct 327 ms 31740 KB Output is correct
11 Correct 275 ms 31864 KB Output is correct
12 Correct 287 ms 31736 KB Output is correct
13 Correct 277 ms 31992 KB Output is correct
14 Correct 237 ms 31736 KB Output is correct
15 Correct 295 ms 31856 KB Output is correct
16 Correct 297 ms 31864 KB Output is correct
17 Correct 246 ms 31864 KB Output is correct
18 Correct 311 ms 31868 KB Output is correct
19 Correct 368 ms 31864 KB Output is correct
20 Correct 277 ms 31864 KB Output is correct
21 Correct 286 ms 31736 KB Output is correct
22 Correct 284 ms 31996 KB Output is correct
23 Correct 315 ms 31736 KB Output is correct
24 Correct 276 ms 31844 KB Output is correct
25 Correct 275 ms 31864 KB Output is correct
26 Correct 309 ms 31864 KB Output is correct
27 Correct 324 ms 31864 KB Output is correct
28 Correct 282 ms 31992 KB Output is correct
29 Correct 285 ms 31892 KB Output is correct
30 Correct 282 ms 31864 KB Output is correct
31 Correct 219 ms 31992 KB Output is correct
32 Correct 302 ms 31888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 308 ms 31864 KB Output is correct
2 Correct 300 ms 31964 KB Output is correct
3 Correct 336 ms 31864 KB Output is correct
4 Correct 348 ms 31880 KB Output is correct
5 Correct 347 ms 31864 KB Output is correct
6 Correct 315 ms 31868 KB Output is correct
7 Correct 277 ms 31736 KB Output is correct
8 Correct 315 ms 31736 KB Output is correct
9 Correct 340 ms 31864 KB Output is correct
10 Correct 289 ms 31736 KB Output is correct
11 Correct 347 ms 31864 KB Output is correct
12 Correct 456 ms 31992 KB Output is correct
13 Correct 258 ms 31864 KB Output is correct
14 Correct 327 ms 31864 KB Output is correct
15 Correct 324 ms 31864 KB Output is correct
16 Correct 347 ms 31864 KB Output is correct
17 Correct 309 ms 31992 KB Output is correct
18 Correct 302 ms 31852 KB Output is correct
19 Correct 399 ms 31864 KB Output is correct
20 Correct 278 ms 31864 KB Output is correct
21 Correct 295 ms 31864 KB Output is correct
22 Correct 277 ms 31736 KB Output is correct
23 Correct 278 ms 31864 KB Output is correct
24 Correct 273 ms 31864 KB Output is correct
25 Correct 312 ms 31864 KB Output is correct
26 Correct 282 ms 31864 KB Output is correct
27 Correct 346 ms 31992 KB Output is correct
28 Correct 336 ms 31864 KB Output is correct
29 Correct 461 ms 31992 KB Output is correct
30 Correct 319 ms 31736 KB Output is correct
31 Correct 287 ms 32008 KB Output is correct
32 Correct 323 ms 31992 KB Output is correct
33 Correct 296 ms 31736 KB Output is correct
34 Correct 318 ms 31992 KB Output is correct
35 Correct 336 ms 31996 KB Output is correct
36 Correct 320 ms 31864 KB Output is correct
37 Correct 342 ms 31736 KB Output is correct
38 Correct 282 ms 31864 KB Output is correct
39 Correct 457 ms 31992 KB Output is correct
40 Correct 273 ms 31864 KB Output is correct
41 Correct 277 ms 31864 KB Output is correct
42 Correct 346 ms 31736 KB Output is correct
43 Correct 340 ms 31864 KB Output is correct
44 Correct 416 ms 31852 KB Output is correct
45 Correct 276 ms 31864 KB Output is correct
46 Correct 289 ms 31864 KB Output is correct
47 Correct 297 ms 31992 KB Output is correct
48 Correct 326 ms 31864 KB Output is correct
49 Correct 297 ms 31736 KB Output is correct
50 Correct 343 ms 31864 KB Output is correct
51 Correct 318 ms 31864 KB Output is correct
52 Correct 270 ms 31992 KB Output is correct
53 Correct 356 ms 31992 KB Output is correct
54 Correct 290 ms 31864 KB Output is correct
55 Correct 316 ms 31864 KB Output is correct
56 Correct 271 ms 31736 KB Output is correct
57 Correct 342 ms 31864 KB Output is correct
58 Correct 331 ms 31864 KB Output is correct
59 Correct 289 ms 31864 KB Output is correct
60 Correct 309 ms 31736 KB Output is correct
61 Correct 350 ms 31912 KB Output is correct
62 Correct 326 ms 31736 KB Output is correct
63 Correct 460 ms 31992 KB Output is correct
64 Correct 288 ms 31868 KB Output is correct
65 Correct 371 ms 31864 KB Output is correct
66 Correct 406 ms 31992 KB Output is correct
67 Correct 311 ms 31864 KB Output is correct
68 Correct 272 ms 31864 KB Output is correct
69 Correct 265 ms 31864 KB Output is correct
70 Correct 334 ms 31992 KB Output is correct
71 Correct 305 ms 31864 KB Output is correct
72 Correct 255 ms 31864 KB Output is correct
73 Correct 374 ms 31936 KB Output is correct
74 Correct 246 ms 31864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 217 ms 31864 KB Output is correct
2 Correct 220 ms 31864 KB Output is correct
3 Correct 275 ms 31864 KB Output is correct
4 Correct 284 ms 31864 KB Output is correct
5 Correct 252 ms 31864 KB Output is correct
6 Correct 307 ms 31864 KB Output is correct
7 Correct 283 ms 31736 KB Output is correct
8 Correct 330 ms 31864 KB Output is correct
9 Correct 306 ms 31880 KB Output is correct
10 Correct 301 ms 31964 KB Output is correct
11 Correct 297 ms 31864 KB Output is correct
12 Correct 370 ms 31864 KB Output is correct
13 Correct 238 ms 31736 KB Output is correct
14 Correct 294 ms 31908 KB Output is correct
15 Correct 300 ms 31960 KB Output is correct
16 Correct 336 ms 31864 KB Output is correct
17 Correct 318 ms 31864 KB Output is correct
18 Correct 305 ms 31864 KB Output is correct
19 Correct 308 ms 31864 KB Output is correct
20 Correct 305 ms 31992 KB Output is correct
21 Correct 485 ms 31848 KB Output is correct
22 Correct 285 ms 31864 KB Output is correct
23 Correct 328 ms 31864 KB Output is correct
24 Correct 325 ms 31864 KB Output is correct
25 Correct 315 ms 31864 KB Output is correct
26 Correct 266 ms 31868 KB Output is correct
27 Correct 315 ms 31736 KB Output is correct
28 Correct 433 ms 31992 KB Output is correct
29 Correct 282 ms 31736 KB Output is correct
30 Correct 314 ms 31864 KB Output is correct
31 Correct 312 ms 31736 KB Output is correct
32 Correct 332 ms 31864 KB Output is correct
33 Correct 347 ms 31864 KB Output is correct
34 Correct 324 ms 31736 KB Output is correct
35 Correct 276 ms 31864 KB Output is correct
36 Correct 288 ms 31736 KB Output is correct
37 Correct 300 ms 31736 KB Output is correct
38 Correct 316 ms 31860 KB Output is correct
39 Correct 340 ms 31852 KB Output is correct
40 Correct 366 ms 31864 KB Output is correct
41 Correct 309 ms 31864 KB Output is correct
42 Correct 285 ms 31908 KB Output is correct
43 Correct 352 ms 31884 KB Output is correct
44 Correct 320 ms 31864 KB Output is correct
45 Correct 321 ms 31864 KB Output is correct
46 Correct 326 ms 31992 KB Output is correct
47 Correct 355 ms 31864 KB Output is correct
48 Correct 371 ms 31856 KB Output is correct
49 Correct 284 ms 31736 KB Output is correct
50 Correct 290 ms 31864 KB Output is correct
51 Correct 336 ms 31964 KB Output is correct
52 Execution timed out 1068 ms 31992 KB Time limit exceeded
53 Halted 0 ms 0 KB -