답안 #168627

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
168627 2019-12-14T15:44:44 Z Milki Bali Sculptures (APIO15_sculpture) C++14
71 / 100
1000 ms 31964 KB
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#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 = 40; 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 245 ms 31852 KB Output is correct
2 Correct 224 ms 31864 KB Output is correct
3 Correct 244 ms 31848 KB Output is correct
4 Correct 253 ms 31860 KB Output is correct
5 Correct 246 ms 31736 KB Output is correct
6 Correct 219 ms 31856 KB Output is correct
7 Correct 247 ms 31928 KB Output is correct
8 Correct 250 ms 31860 KB Output is correct
9 Correct 251 ms 31852 KB Output is correct
10 Correct 237 ms 31736 KB Output is correct
11 Correct 237 ms 31736 KB Output is correct
12 Correct 251 ms 31856 KB Output is correct
13 Correct 251 ms 31864 KB Output is correct
14 Correct 236 ms 31864 KB Output is correct
15 Correct 249 ms 31736 KB Output is correct
16 Correct 251 ms 31736 KB Output is correct
17 Correct 250 ms 31852 KB Output is correct
18 Correct 234 ms 31856 KB Output is correct
19 Correct 234 ms 31856 KB Output is correct
20 Correct 256 ms 31860 KB Output is correct
21 Correct 249 ms 31736 KB Output is correct
22 Correct 240 ms 31852 KB Output is correct
23 Correct 213 ms 31860 KB Output is correct
24 Correct 254 ms 31852 KB Output is correct
25 Correct 251 ms 31848 KB Output is correct
26 Correct 250 ms 31852 KB Output is correct
27 Correct 236 ms 31736 KB Output is correct
28 Correct 249 ms 31852 KB Output is correct
29 Correct 248 ms 31848 KB Output is correct
30 Correct 226 ms 31852 KB Output is correct
31 Correct 249 ms 31852 KB Output is correct
32 Correct 259 ms 31856 KB Output is correct
33 Correct 249 ms 31868 KB Output is correct
34 Correct 240 ms 31864 KB Output is correct
35 Correct 239 ms 31736 KB Output is correct
36 Correct 249 ms 31864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 294 ms 31860 KB Output is correct
2 Correct 250 ms 31856 KB Output is correct
3 Correct 238 ms 31856 KB Output is correct
4 Correct 234 ms 31736 KB Output is correct
5 Correct 255 ms 31864 KB Output is correct
6 Correct 245 ms 31736 KB Output is correct
7 Correct 242 ms 31856 KB Output is correct
8 Correct 253 ms 31860 KB Output is correct
9 Correct 257 ms 31852 KB Output is correct
10 Correct 364 ms 31864 KB Output is correct
11 Correct 289 ms 31852 KB Output is correct
12 Correct 247 ms 31852 KB Output is correct
13 Correct 258 ms 31736 KB Output is correct
14 Correct 249 ms 31864 KB Output is correct
15 Correct 261 ms 31952 KB Output is correct
16 Correct 255 ms 31852 KB Output is correct
17 Correct 243 ms 31852 KB Output is correct
18 Correct 249 ms 31852 KB Output is correct
19 Correct 257 ms 31736 KB Output is correct
20 Correct 252 ms 31860 KB Output is correct
21 Correct 232 ms 31864 KB Output is correct
22 Correct 248 ms 31852 KB Output is correct
23 Correct 268 ms 31848 KB Output is correct
24 Correct 251 ms 31852 KB Output is correct
25 Correct 231 ms 31856 KB Output is correct
26 Correct 311 ms 31864 KB Output is correct
27 Correct 247 ms 31848 KB Output is correct
28 Correct 249 ms 31852 KB Output is correct
29 Correct 283 ms 31852 KB Output is correct
30 Correct 249 ms 31736 KB Output is correct
31 Correct 237 ms 31868 KB Output is correct
32 Correct 245 ms 31736 KB Output is correct
33 Correct 256 ms 31736 KB Output is correct
34 Correct 253 ms 31856 KB Output is correct
35 Correct 236 ms 31852 KB Output is correct
36 Correct 252 ms 31852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 251 ms 31852 KB Output is correct
2 Correct 253 ms 31864 KB Output is correct
3 Correct 243 ms 31852 KB Output is correct
4 Correct 251 ms 31852 KB Output is correct
5 Correct 253 ms 31852 KB Output is correct
6 Correct 236 ms 31864 KB Output is correct
7 Correct 227 ms 31848 KB Output is correct
8 Correct 250 ms 31964 KB Output is correct
9 Correct 247 ms 31864 KB Output is correct
10 Correct 249 ms 31848 KB Output is correct
11 Correct 244 ms 31852 KB Output is correct
12 Correct 254 ms 31852 KB Output is correct
13 Correct 244 ms 31736 KB Output is correct
14 Correct 238 ms 31848 KB Output is correct
15 Correct 248 ms 31736 KB Output is correct
16 Correct 253 ms 31852 KB Output is correct
17 Correct 235 ms 31848 KB Output is correct
18 Correct 232 ms 31736 KB Output is correct
19 Correct 254 ms 31736 KB Output is correct
20 Correct 258 ms 31852 KB Output is correct
21 Correct 231 ms 31736 KB Output is correct
22 Correct 215 ms 31856 KB Output is correct
23 Correct 249 ms 31852 KB Output is correct
24 Correct 248 ms 31852 KB Output is correct
25 Correct 246 ms 31864 KB Output is correct
26 Correct 238 ms 31736 KB Output is correct
27 Correct 254 ms 31860 KB Output is correct
28 Correct 250 ms 31736 KB Output is correct
29 Correct 247 ms 31740 KB Output is correct
30 Correct 276 ms 31852 KB Output is correct
31 Correct 257 ms 31856 KB Output is correct
32 Correct 241 ms 31856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 246 ms 31856 KB Output is correct
2 Correct 252 ms 31736 KB Output is correct
3 Correct 253 ms 31848 KB Output is correct
4 Correct 246 ms 31864 KB Output is correct
5 Correct 245 ms 31848 KB Output is correct
6 Correct 243 ms 31736 KB Output is correct
7 Correct 249 ms 31852 KB Output is correct
8 Correct 247 ms 31736 KB Output is correct
9 Correct 245 ms 31848 KB Output is correct
10 Correct 243 ms 31856 KB Output is correct
11 Correct 254 ms 31860 KB Output is correct
12 Correct 209 ms 31736 KB Output is correct
13 Correct 210 ms 31848 KB Output is correct
14 Correct 239 ms 31736 KB Output is correct
15 Correct 245 ms 31864 KB Output is correct
16 Correct 323 ms 31848 KB Output is correct
17 Correct 248 ms 31760 KB Output is correct
18 Correct 239 ms 31736 KB Output is correct
19 Correct 252 ms 31864 KB Output is correct
20 Correct 255 ms 31844 KB Output is correct
21 Correct 366 ms 31824 KB Output is correct
22 Correct 253 ms 31852 KB Output is correct
23 Correct 245 ms 31848 KB Output is correct
24 Correct 260 ms 31852 KB Output is correct
25 Correct 251 ms 31964 KB Output is correct
26 Correct 294 ms 31864 KB Output is correct
27 Correct 253 ms 31780 KB Output is correct
28 Correct 240 ms 31852 KB Output is correct
29 Correct 228 ms 31848 KB Output is correct
30 Correct 250 ms 31864 KB Output is correct
31 Correct 247 ms 31872 KB Output is correct
32 Correct 238 ms 31852 KB Output is correct
33 Correct 248 ms 31864 KB Output is correct
34 Correct 272 ms 31848 KB Output is correct
35 Correct 254 ms 31848 KB Output is correct
36 Correct 243 ms 31852 KB Output is correct
37 Correct 213 ms 31848 KB Output is correct
38 Correct 280 ms 31852 KB Output is correct
39 Correct 254 ms 31856 KB Output is correct
40 Correct 244 ms 31852 KB Output is correct
41 Correct 231 ms 31736 KB Output is correct
42 Correct 248 ms 31864 KB Output is correct
43 Correct 259 ms 31864 KB Output is correct
44 Correct 253 ms 31852 KB Output is correct
45 Correct 231 ms 31736 KB Output is correct
46 Correct 233 ms 31736 KB Output is correct
47 Correct 249 ms 31964 KB Output is correct
48 Correct 239 ms 31740 KB Output is correct
49 Correct 237 ms 31852 KB Output is correct
50 Correct 244 ms 31736 KB Output is correct
51 Correct 247 ms 31856 KB Output is correct
52 Correct 249 ms 31848 KB Output is correct
53 Correct 271 ms 31856 KB Output is correct
54 Correct 249 ms 31736 KB Output is correct
55 Correct 252 ms 31852 KB Output is correct
56 Correct 234 ms 31736 KB Output is correct
57 Correct 258 ms 31848 KB Output is correct
58 Correct 241 ms 31848 KB Output is correct
59 Correct 251 ms 31852 KB Output is correct
60 Correct 248 ms 31844 KB Output is correct
61 Correct 198 ms 31736 KB Output is correct
62 Correct 249 ms 31864 KB Output is correct
63 Correct 249 ms 31868 KB Output is correct
64 Correct 210 ms 31852 KB Output is correct
65 Correct 241 ms 31856 KB Output is correct
66 Correct 253 ms 31852 KB Output is correct
67 Correct 241 ms 31848 KB Output is correct
68 Correct 237 ms 31864 KB Output is correct
69 Correct 239 ms 31852 KB Output is correct
70 Correct 254 ms 31736 KB Output is correct
71 Correct 259 ms 31852 KB Output is correct
72 Correct 253 ms 31736 KB Output is correct
73 Correct 251 ms 31836 KB Output is correct
74 Correct 289 ms 31856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 250 ms 31852 KB Output is correct
2 Correct 241 ms 31736 KB Output is correct
3 Correct 247 ms 31852 KB Output is correct
4 Correct 251 ms 31864 KB Output is correct
5 Correct 202 ms 31852 KB Output is correct
6 Correct 226 ms 31852 KB Output is correct
7 Correct 204 ms 31736 KB Output is correct
8 Correct 236 ms 31848 KB Output is correct
9 Correct 255 ms 31852 KB Output is correct
10 Correct 246 ms 31736 KB Output is correct
11 Correct 233 ms 31860 KB Output is correct
12 Correct 251 ms 31852 KB Output is correct
13 Correct 256 ms 31844 KB Output is correct
14 Correct 249 ms 31856 KB Output is correct
15 Correct 249 ms 31848 KB Output is correct
16 Correct 248 ms 31736 KB Output is correct
17 Correct 252 ms 31736 KB Output is correct
18 Correct 246 ms 31864 KB Output is correct
19 Correct 246 ms 31736 KB Output is correct
20 Correct 255 ms 31864 KB Output is correct
21 Correct 250 ms 31852 KB Output is correct
22 Correct 244 ms 31852 KB Output is correct
23 Correct 232 ms 31856 KB Output is correct
24 Correct 234 ms 31852 KB Output is correct
25 Correct 254 ms 31848 KB Output is correct
26 Correct 253 ms 31864 KB Output is correct
27 Correct 235 ms 31852 KB Output is correct
28 Correct 238 ms 31848 KB Output is correct
29 Correct 255 ms 31864 KB Output is correct
30 Correct 249 ms 31736 KB Output is correct
31 Correct 212 ms 31864 KB Output is correct
32 Correct 238 ms 31852 KB Output is correct
33 Correct 259 ms 31852 KB Output is correct
34 Correct 247 ms 31736 KB Output is correct
35 Correct 255 ms 31864 KB Output is correct
36 Correct 247 ms 31736 KB Output is correct
37 Correct 253 ms 31852 KB Output is correct
38 Correct 246 ms 31828 KB Output is correct
39 Correct 207 ms 31736 KB Output is correct
40 Correct 253 ms 31852 KB Output is correct
41 Correct 260 ms 31852 KB Output is correct
42 Correct 229 ms 31736 KB Output is correct
43 Correct 240 ms 31860 KB Output is correct
44 Correct 251 ms 31736 KB Output is correct
45 Correct 256 ms 31852 KB Output is correct
46 Correct 242 ms 31852 KB Output is correct
47 Correct 233 ms 31860 KB Output is correct
48 Correct 259 ms 31856 KB Output is correct
49 Correct 255 ms 31768 KB Output is correct
50 Correct 240 ms 31736 KB Output is correct
51 Correct 267 ms 31856 KB Output is correct
52 Correct 853 ms 31896 KB Output is correct
53 Correct 238 ms 31912 KB Output is correct
54 Execution timed out 1072 ms 31868 KB Time limit exceeded
55 Halted 0 ms 0 KB -