답안 #544307

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
544307 2022-04-01T16:02:24 Z SavicS Bali Sculptures (APIO15_sculpture) C++17
71 / 100
1000 ms 1748 KB
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
 
#define ff(i,a,b) for(int i = a; i <= b; i++)
#define fb(i,b,a) for(int i = b; i >= a; i--)
#define trav(a,x) for (auto& a : x)
 
#define sz(a) (int)(a).size()
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// os.order_of_key(k) the number of elements in the os less than k
// *os.find_by_order(k)  print the k-th smallest number in os(0-based)

const int mod = 1000000007;
const int inf = 1e9 + 5;
const int mxN = 2005; 

int n, A, B;
int niz[mxN];

bool dp[mxN][mxN];
bool check(ll msk){
    // da li imam resenje tako da je svaki bit iz mask

    ff(i,0,n)ff(j,0,B)dp[i][j] = 0;


    dp[0][0] = 1;
    ff(i,1,n){
        ff(j,1,B){
            ll X = 0;
            fb(l,i,1){
                X += niz[l];
                if((X & msk) == X){
                    dp[i][j] |= dp[l - 1][j - 1];
                }
            }
        }
    }

    ff(j,A,B)if(dp[n][j] == 1)return 1;
    return 0;

}

int main() {
    cin.tie(0)->sync_with_stdio(0);

    cin >> n >> A >> B;
    ff(i,1,n)cin >> niz[i];

    // znaci ja hocu da or bude minimalan

    ll rez = (1ll << 41) - 1;
    fb(i,40,0){

        if(check(rez ^ (1ll << i))){
            rez ^= (1ll << i);
        }

    }

    cout << rez << '\n';

    return 0;
}
/*
 
6 1 3 
8 1 2 1 5 4
 
// probati bojenje sahovski
*/
 
 
 
 
 
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 360 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 2 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 2 ms 336 KB Output is correct
35 Correct 2 ms 340 KB Output is correct
36 Correct 2 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 456 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 3 ms 468 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 3 ms 340 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 2 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 6 ms 468 KB Output is correct
27 Correct 17 ms 468 KB Output is correct
28 Correct 36 ms 468 KB Output is correct
29 Correct 36 ms 512 KB Output is correct
30 Correct 1 ms 464 KB Output is correct
31 Correct 18 ms 540 KB Output is correct
32 Correct 27 ms 540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
41 Correct 3 ms 348 KB Output is correct
42 Correct 3 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 2 ms 340 KB Output is correct
45 Correct 2 ms 340 KB Output is correct
46 Correct 2 ms 340 KB Output is correct
47 Correct 3 ms 340 KB Output is correct
48 Correct 2 ms 468 KB Output is correct
49 Correct 5 ms 468 KB Output is correct
50 Correct 17 ms 468 KB Output is correct
51 Correct 38 ms 516 KB Output is correct
52 Correct 38 ms 540 KB Output is correct
53 Correct 1 ms 468 KB Output is correct
54 Correct 18 ms 468 KB Output is correct
55 Correct 29 ms 548 KB Output is correct
56 Correct 2 ms 340 KB Output is correct
57 Correct 4 ms 468 KB Output is correct
58 Correct 14 ms 520 KB Output is correct
59 Correct 26 ms 468 KB Output is correct
60 Correct 25 ms 544 KB Output is correct
61 Correct 1 ms 468 KB Output is correct
62 Correct 26 ms 468 KB Output is correct
63 Correct 26 ms 536 KB Output is correct
64 Correct 28 ms 468 KB Output is correct
65 Correct 2 ms 340 KB Output is correct
66 Correct 2 ms 468 KB Output is correct
67 Correct 4 ms 468 KB Output is correct
68 Correct 12 ms 516 KB Output is correct
69 Correct 24 ms 468 KB Output is correct
70 Correct 23 ms 468 KB Output is correct
71 Correct 1 ms 468 KB Output is correct
72 Correct 25 ms 468 KB Output is correct
73 Correct 18 ms 468 KB Output is correct
74 Correct 17 ms 540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 2 ms 340 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 3 ms 436 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 3 ms 340 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 3 ms 340 KB Output is correct
35 Correct 2 ms 340 KB Output is correct
36 Correct 5 ms 468 KB Output is correct
37 Correct 17 ms 516 KB Output is correct
38 Correct 37 ms 468 KB Output is correct
39 Correct 36 ms 520 KB Output is correct
40 Correct 1 ms 468 KB Output is correct
41 Correct 19 ms 468 KB Output is correct
42 Correct 29 ms 520 KB Output is correct
43 Correct 2 ms 444 KB Output is correct
44 Correct 4 ms 468 KB Output is correct
45 Correct 12 ms 520 KB Output is correct
46 Correct 23 ms 468 KB Output is correct
47 Correct 22 ms 468 KB Output is correct
48 Correct 1 ms 468 KB Output is correct
49 Correct 25 ms 468 KB Output is correct
50 Correct 24 ms 540 KB Output is correct
51 Correct 5 ms 468 KB Output is correct
52 Correct 627 ms 1464 KB Output is correct
53 Execution timed out 1088 ms 1748 KB Time limit exceeded
54 Halted 0 ms 0 KB -