Submission #866954

# Submission time Handle Problem Language Result Execution time Memory
866954 2023-10-27T13:42:10 Z tothanhdat1421 Bali Sculptures (APIO15_sculpture) C++14
50 / 100
91 ms 608 KB
/* ========================  INCL  ======================== */
#include <iostream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

using namespace std;

/* Code by { To Thanh Dat } 12TT THPT Chuyen Ben Tre */

/* ========================TEMPLATE======================== */
#define ll  long long
#define ull unsigned long long
#define pii pair<int, int>
#define vi  vector<int>
#define vii vector<pair<int, int>>
#define mii map<int, int>
#define pb  push_back
#define eb  emplace_back
#define mp  make_pair
#define fi  first
#define se  second

#define For(i, a, b)   for(int i=a; i<=b; ++i)
#define rFor(i, a, b)  for(int i=a; i>=b; --i)
#define Rep(i, n)      for(int i = 0; i < (int)n; ++i)
#define rRep(i, n)     for(int i = (int)n - 1; i >= 0; --i)

/* ========================CONSTANT======================== */
const int intINF = -1 ^ (1<<31);
const ll llINF = -1LL ^ (1LL << 63);
const int mod = 1e9+7;
const int N = 2000+1;

/* ========================VARIABLE======================== */
int n, A, B;
ll a[N];
ll pref[N], F[N+1];

/* ========================  MAIN  ======================== */
bool can(ll mask)
{
    For(i, 1, n+1) F[i] = 1e5;
    F[1] = 0;
    For(i, 1, n)
    {
        if(F[i] >= 1e5) continue;
        ll cursum = 0;
        For(j, i, n)
        {
            cursum += a[j];
            if((cursum & mask) == 0)
            {
                F[j+1] = min(F[j+1], 1 + F[i]);
            }
        }
    }

    // cout << "mask = " << mask << endl;
    // For(i, 0, n) cout << F[i] << ' ';
    // cout << endl;

    return (A <= F[n+1] && F[n+1] <= B);
}

int main()
{
    if(fopen("APIO15_sculpture.inp", "r"))
    {
        freopen("APIO15_sculpture.inp", "r", stdin);
        freopen("APIO15_sculpture.out", "w", stdout);
    }
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    
    cin >> n >> A >> B;
    For(i, 1, n) cin >> a[i];
    // pref[0] = 0;
    // For(i, 1, n) pref[i] = pref[i-1] + a[i];    

    ll cur_mask = 0;
    rFor(i, 60, 0)
    {
        if(can(cur_mask | (1ll << i)))
        {
            cur_mask = cur_mask | (1ll << i);
            // cout << "   => cur mask = " << cur_mask << endl;
        }
    }

    cout << (1ll << 61)-1 - cur_mask;
    return 0;
}

Compilation message

sculpture.cpp: In function 'int main()':
sculpture.cpp:75:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |         freopen("APIO15_sculpture.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:76:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |         freopen("APIO15_sculpture.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 460 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Incorrect 0 ms 344 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 500 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Incorrect 0 ms 344 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 352 KB Output is correct
7 Correct 0 ms 356 KB Output is correct
8 Correct 0 ms 352 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 608 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 352 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 600 KB Output is correct
21 Correct 0 ms 352 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 428 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 1 ms 604 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 352 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 360 KB Output is correct
2 Correct 0 ms 356 KB Output is correct
3 Correct 0 ms 360 KB Output is correct
4 Correct 0 ms 448 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 0 ms 360 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Incorrect 0 ms 348 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 352 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 460 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 464 KB Output is correct
42 Correct 1 ms 456 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 344 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 1 ms 344 KB Output is correct
52 Correct 7 ms 348 KB Output is correct
53 Correct 8 ms 348 KB Output is correct
54 Correct 31 ms 468 KB Output is correct
55 Correct 19 ms 348 KB Output is correct
56 Correct 52 ms 484 KB Output is correct
57 Correct 53 ms 344 KB Output is correct
58 Correct 59 ms 352 KB Output is correct
59 Correct 70 ms 352 KB Output is correct
60 Correct 56 ms 352 KB Output is correct
61 Correct 1 ms 344 KB Output is correct
62 Correct 8 ms 348 KB Output is correct
63 Correct 25 ms 604 KB Output is correct
64 Correct 13 ms 344 KB Output is correct
65 Correct 25 ms 348 KB Output is correct
66 Correct 38 ms 484 KB Output is correct
67 Correct 63 ms 348 KB Output is correct
68 Correct 91 ms 488 KB Output is correct
69 Correct 50 ms 348 KB Output is correct