Submission #1130722

#TimeUsernameProblemLanguageResultExecution timeMemory
1130722Hamed_GhaffariBali Sculptures (APIO15_sculpture)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,sse4,sse4.2,lzcnt,popcnt") using ll = long long; const int INF = 1e9; const int MXN = 2002; const int LOG = 41; int n, A, B; ll ps[MXN]; namespace n2log { int dis[MXN]; ll val; bool check() { fill(dis+1, dis+n+1, INF); for(int i=0; i<n; i++) for(int j=i+1; j<=n; j++) if(!((ps[j]-ps[i])&val)) dis[j] = min(dis[j], dis[i]+1); return dis[n]<=B; } void solve() { ll ans=0; for(int i=LOG-1; i>=0; i--) { val ^= 1ll<<i; if(!check()) val ^= 1ll<<i, ans ^= 1ll<<i; } cout << ans << '\n'; } } namespace n3log { const int MXN = 102; const int LOG = 37; bool dp[MXN][MXN]; ll val; bool check() { memset(dp, 0, sizeof(dp)); dp[0][0] = 1; for(int i=0; i<n; i++) for(int x=0; x<B; x++) if(dp[i][x]) for(int j=i+1; j<=n; j++) if(!((ps[j]-ps[i])&val) dp[j][x+1] = 1; for(int x=A; x<=B; x++) if(dp[n][x]) return 1; return 0; } void solve() { ll ans=0; for(int i=LOG-1; i>=0; i--) { val ^= 1ll<<i; if(!check()) val ^= 1ll<<i, ans ^= 1ll<<i; } cout << ans << '\n'; } } int32_t main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); cin >> n >> A >> B; for(int i=1; i<=n; i++) { cin >> ps[i]; ps[i] += ps[i-1]; } if(A==1) n2log::solve(); else n3log::solve(); return 0; }

Compilation message (stderr)

sculpture.cpp: In function 'bool n3log::check()':
sculpture.cpp:50:36: error: expected ';' before 'dp'
   50 |             if(!((ps[j]-ps[i])&val)
      |                                    ^
      |                                    ;
   51 |               dp[j][x+1] = 1;
      |               ~~                    
sculpture.cpp:52:5: error: expected primary-expression before 'for'
   52 |     for(int x=A; x<=B; x++)
      |     ^~~
sculpture.cpp:51:30: error: expected ')' before 'for'
   51 |               dp[j][x+1] = 1;
      |                              ^
      |                              )
   52 |     for(int x=A; x<=B; x++)
      |     ~~~                       
sculpture.cpp:50:15: note: to match this '('
   50 |             if(!((ps[j]-ps[i])&val)
      |               ^
sculpture.cpp:52:18: error: 'x' was not declared in this scope
   52 |     for(int x=A; x<=B; x++)
      |                  ^