답안 #168623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
168623 2019-12-14T15:37:47 Z Milki Bali Sculptures (APIO15_sculpture) C++14
37 / 100
540 ms 31992 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 get(int l, int r){
  if(l > 0)
    return prefix[r] - prefix[l - 1];
  else
    return prefix[r];
}

int rek(int pos, int num, int 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);
    }
  }

  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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 289 ms 31864 KB Output is correct
2 Correct 334 ms 31864 KB Output is correct
3 Correct 325 ms 31736 KB Output is correct
4 Correct 264 ms 31980 KB Output is correct
5 Correct 231 ms 31864 KB Output is correct
6 Correct 265 ms 31736 KB Output is correct
7 Correct 315 ms 31964 KB Output is correct
8 Correct 270 ms 31992 KB Output is correct
9 Correct 273 ms 31864 KB Output is correct
10 Correct 235 ms 31864 KB Output is correct
11 Correct 285 ms 31864 KB Output is correct
12 Correct 263 ms 31736 KB Output is correct
13 Correct 239 ms 31736 KB Output is correct
14 Correct 262 ms 31864 KB Output is correct
15 Correct 267 ms 31864 KB Output is correct
16 Correct 264 ms 31864 KB Output is correct
17 Correct 288 ms 31992 KB Output is correct
18 Correct 382 ms 31864 KB Output is correct
19 Correct 293 ms 31860 KB Output is correct
20 Correct 294 ms 31860 KB Output is correct
21 Correct 266 ms 31740 KB Output is correct
22 Correct 288 ms 31864 KB Output is correct
23 Correct 327 ms 31940 KB Output is correct
24 Correct 288 ms 31736 KB Output is correct
25 Correct 329 ms 31864 KB Output is correct
26 Correct 297 ms 31864 KB Output is correct
27 Correct 269 ms 31732 KB Output is correct
28 Correct 340 ms 31864 KB Output is correct
29 Correct 244 ms 31736 KB Output is correct
30 Incorrect 289 ms 31736 KB Output isn't correct
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 329 ms 31736 KB Output is correct
2 Correct 310 ms 31856 KB Output is correct
3 Correct 345 ms 31964 KB Output is correct
4 Correct 384 ms 31864 KB Output is correct
5 Correct 346 ms 31868 KB Output is correct
6 Correct 355 ms 31864 KB Output is correct
7 Correct 313 ms 31864 KB Output is correct
8 Correct 292 ms 31992 KB Output is correct
9 Correct 327 ms 31864 KB Output is correct
10 Correct 307 ms 31864 KB Output is correct
11 Correct 256 ms 31864 KB Output is correct
12 Correct 268 ms 31864 KB Output is correct
13 Correct 324 ms 31888 KB Output is correct
14 Correct 329 ms 31888 KB Output is correct
15 Correct 304 ms 31740 KB Output is correct
16 Correct 274 ms 31860 KB Output is correct
17 Correct 278 ms 31864 KB Output is correct
18 Correct 246 ms 31964 KB Output is correct
19 Correct 284 ms 31864 KB Output is correct
20 Correct 243 ms 31864 KB Output is correct
21 Correct 270 ms 31892 KB Output is correct
22 Correct 329 ms 31864 KB Output is correct
23 Correct 301 ms 31736 KB Output is correct
24 Correct 288 ms 31864 KB Output is correct
25 Correct 253 ms 31736 KB Output is correct
26 Correct 299 ms 31864 KB Output is correct
27 Correct 306 ms 31896 KB Output is correct
28 Correct 282 ms 31864 KB Output is correct
29 Correct 332 ms 31864 KB Output is correct
30 Correct 327 ms 31864 KB Output is correct
31 Correct 309 ms 31864 KB Output is correct
32 Correct 302 ms 31736 KB Output is correct
33 Correct 281 ms 31736 KB Output is correct
34 Correct 344 ms 31856 KB Output is correct
35 Correct 284 ms 31864 KB Output is correct
36 Correct 301 ms 31864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 289 ms 31736 KB Output is correct
2 Correct 282 ms 31864 KB Output is correct
3 Correct 335 ms 31736 KB Output is correct
4 Correct 281 ms 31864 KB Output is correct
5 Correct 298 ms 31856 KB Output is correct
6 Correct 277 ms 31736 KB Output is correct
7 Correct 291 ms 31864 KB Output is correct
8 Correct 247 ms 31864 KB Output is correct
9 Correct 391 ms 31864 KB Output is correct
10 Correct 290 ms 31864 KB Output is correct
11 Correct 313 ms 31864 KB Output is correct
12 Correct 293 ms 31864 KB Output is correct
13 Correct 292 ms 31740 KB Output is correct
14 Correct 514 ms 31736 KB Output is correct
15 Correct 428 ms 31992 KB Output is correct
16 Correct 316 ms 31864 KB Output is correct
17 Correct 332 ms 31864 KB Output is correct
18 Correct 345 ms 31864 KB Output is correct
19 Correct 298 ms 31992 KB Output is correct
20 Correct 311 ms 31864 KB Output is correct
21 Correct 333 ms 31964 KB Output is correct
22 Correct 331 ms 31992 KB Output is correct
23 Correct 335 ms 31836 KB Output is correct
24 Correct 330 ms 31964 KB Output is correct
25 Correct 363 ms 31864 KB Output is correct
26 Correct 374 ms 31864 KB Output is correct
27 Correct 360 ms 31864 KB Output is correct
28 Correct 371 ms 31864 KB Output is correct
29 Correct 368 ms 31864 KB Output is correct
30 Correct 518 ms 31856 KB Output is correct
31 Correct 540 ms 31856 KB Output is correct
32 Correct 438 ms 31860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 335 ms 31864 KB Output is correct
2 Correct 404 ms 31860 KB Output is correct
3 Correct 331 ms 31864 KB Output is correct
4 Correct 317 ms 31864 KB Output is correct
5 Correct 316 ms 31864 KB Output is correct
6 Correct 340 ms 31852 KB Output is correct
7 Correct 362 ms 31864 KB Output is correct
8 Correct 363 ms 31852 KB Output is correct
9 Correct 321 ms 31864 KB Output is correct
10 Correct 330 ms 31736 KB Output is correct
11 Correct 320 ms 31736 KB Output is correct
12 Correct 394 ms 31848 KB Output is correct
13 Correct 422 ms 31992 KB Output is correct
14 Correct 355 ms 31864 KB Output is correct
15 Correct 344 ms 31864 KB Output is correct
16 Correct 306 ms 31860 KB Output is correct
17 Correct 282 ms 31860 KB Output is correct
18 Correct 342 ms 31736 KB Output is correct
19 Correct 317 ms 31864 KB Output is correct
20 Correct 325 ms 31864 KB Output is correct
21 Correct 355 ms 31856 KB Output is correct
22 Correct 303 ms 31736 KB Output is correct
23 Correct 319 ms 31856 KB Output is correct
24 Correct 326 ms 31856 KB Output is correct
25 Correct 271 ms 31736 KB Output is correct
26 Correct 279 ms 31856 KB Output is correct
27 Correct 334 ms 31864 KB Output is correct
28 Correct 335 ms 31856 KB Output is correct
29 Correct 329 ms 31852 KB Output is correct
30 Incorrect 333 ms 31864 KB Output isn't correct
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 325 ms 31868 KB Output is correct
2 Correct 301 ms 31736 KB Output is correct
3 Correct 322 ms 31736 KB Output is correct
4 Correct 331 ms 31856 KB Output is correct
5 Correct 259 ms 31908 KB Output is correct
6 Correct 309 ms 31736 KB Output is correct
7 Correct 317 ms 31868 KB Output is correct
8 Correct 224 ms 31736 KB Output is correct
9 Correct 220 ms 31912 KB Output is correct
10 Correct 240 ms 31808 KB Output is correct
11 Correct 203 ms 31864 KB Output is correct
12 Correct 226 ms 31860 KB Output is correct
13 Correct 253 ms 31864 KB Output is correct
14 Correct 296 ms 31864 KB Output is correct
15 Correct 314 ms 31864 KB Output is correct
16 Correct 363 ms 31864 KB Output is correct
17 Incorrect 280 ms 31736 KB Output isn't correct
18 Halted 0 ms 0 KB -