Submission #387641

#TimeUsernameProblemLanguageResultExecution timeMemory
387641ismoilovBali Sculptures (APIO15_sculpture)C++14
50 / 100
109 ms452 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...