Submission #387638

# Submission time Handle Problem Language Result Execution time Memory
387638 2021-04-09T04:48:33 Z ismoilov Bali Sculptures (APIO15_sculpture) C++14
50 / 100
113 ms 344 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(), (x).end()
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
#define fv(c) for(int (a) = (1); (a) <= (c); (a)++)
#define fz(c) for(int (a) = (0); (a) < (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
#define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
#define pb push_back
#define in insert
#define ss second
#define ff first
ll d[2001], dd[101][101], s[2001];
void S()
{
	ll n, a, b;
	cin >> n >> a >> b;
	fp(i,0,n){
		ll x;
		cin >> x;
		s[i+1] = s[i]+x;
	}
	
	if(a == 1){
		ll c = (1LL<<42)-1;
		fmm(i,41,0){
			c -= 1LL<<i;
			memset(d, 1, sizeof(d));
			d[0] = 0;
			fpp(j,1,n){
				fpp(k,0,j){
					if(((s[j] - s[k]) | c) == c)
						d[j] = min(d[j], d[k]+1);
				}
			}
			if(d[n] > b)
				c += 1LL << i;
			//cout << c << " ";
		}
		cout << c;
	}
	else{
		ll c = (1LL<<42)-1;
		fmm(i,41,0){
			c -= 1LL-i;
			memset(dd, 0, sizeof(dd));
			dd[0][0] = 1;
			fpp(j,1,n){
				fp(k,0,j){
					if(((s[j] - s[k]) | c) == c){
						fp(l,0,n)
							dd[j][l+1] = dd[k][l];
					}
				}
			}
			ll p=0;
			fpp(j,a,b)
				p |= dd[n][j];
			if(!p)
				c += 1LL<<i;
			//cout << c << " ";
		}
		cout << c;
	}
}
int main()
{
	IOS;
	S();
	/*int t;
	cin >> t;
	while(t--)
		 S();*/
}

Compilation message

sculpture.cpp: In function 'void S()':
sculpture.cpp:9:27: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    9 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
sculpture.cpp:24:2: note: in expansion of macro 'fp'
   24 |  fp(i,0,n){
      |  ^~
sculpture.cpp:14:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   14 | #define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
      |                            ^
sculpture.cpp:32:3: note: in expansion of macro 'fmm'
   32 |   fmm(i,41,0){
      |   ^~~
sculpture.cpp:10:28: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   10 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
sculpture.cpp:36:4: note: in expansion of macro 'fpp'
   36 |    fpp(j,1,n){
      |    ^~~
sculpture.cpp:10:28: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
   10 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
sculpture.cpp:37:5: note: in expansion of macro 'fpp'
   37 |     fpp(k,0,j){
      |     ^~~
sculpture.cpp:14:28: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   14 | #define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
      |                            ^
sculpture.cpp:50:3: note: in expansion of macro 'fmm'
   50 |   fmm(i,41,0){
      |   ^~~
sculpture.cpp:10:28: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   10 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
sculpture.cpp:54:4: note: in expansion of macro 'fpp'
   54 |    fpp(j,1,n){
      |    ^~~
sculpture.cpp:9:27: warning: unnecessary parentheses in declaration of 'k' [-Wparentheses]
    9 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
sculpture.cpp:55:5: note: in expansion of macro 'fp'
   55 |     fp(k,0,j){
      |     ^~
sculpture.cpp:9:27: warning: unnecessary parentheses in declaration of 'l' [-Wparentheses]
    9 | #define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
      |                           ^
sculpture.cpp:57:7: note: in expansion of macro 'fp'
   57 |       fp(l,0,n)
      |       ^~
sculpture.cpp:10:28: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   10 | #define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
      |                            ^
sculpture.cpp:63:4: note: in expansion of macro 'fpp'
   63 |    fpp(j,a,b)
      |    ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Incorrect 1 ms 332 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Incorrect 1 ms 332 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 280 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Incorrect 1 ms 336 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 336 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 204 KB Output is correct
52 Correct 11 ms 344 KB Output is correct
53 Correct 16 ms 332 KB Output is correct
54 Correct 30 ms 344 KB Output is correct
55 Correct 29 ms 344 KB Output is correct
56 Correct 106 ms 344 KB Output is correct
57 Correct 113 ms 344 KB Output is correct
58 Correct 98 ms 344 KB Output is correct
59 Correct 97 ms 332 KB Output is correct
60 Correct 111 ms 332 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 17 ms 332 KB Output is correct
63 Correct 31 ms 344 KB Output is correct
64 Correct 36 ms 336 KB Output is correct
65 Correct 54 ms 332 KB Output is correct
66 Correct 79 ms 332 KB Output is correct
67 Correct 103 ms 332 KB Output is correct
68 Correct 106 ms 336 KB Output is correct
69 Correct 101 ms 332 KB Output is correct