Submission #1079184

#TimeUsernameProblemLanguageResultExecution timeMemory
1079184vjudge1Catfish Farm (IOI22_fish)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define div / #define ll long long #define fore(i, l, r) for(int i=int(l); i<int(r); i++) #define sz(a) int((a).size()) using namespace std; const int INF = 1e9; const int MX = 5e5 + 23; const int MOD = 1000000007; const int MAX_N = 5e5+23; const int N = 1e6; int64_t max_weights(int N, int M, int[] X, int[] Y, int[] W) { int64_t ok=1,ok1=1; fore(i,0,m) { if(x[i] % 2) ok=0; if(x[i] > 1) ok1=0; } int64_t ans=0; if(ok) fore(i,0,m) ans+=w[i]; else if(ok1) { int64_t sum1=0,sum2=0; fore(i,0,m) { if(x[i] == 0) sum1+=w[i]; else sum2+=w[i]; } ans = max(sum1,sum2); } else { int64_t dp[n+5]; memset(dp,0,sizeof dp); int64_t grid[n+5]; memset(grid,0,sizeof grid); fore(i,0,m) grid[x[i]] = w[i]; fore(i,0,n) { dp[i] = grid[i]; if(i > 1) dp[i] += dp[i-2]; if(i) dp[i] = max(dp[i],dp[i-1]); } ans = dp[n-1]; } return ans; }

Compilation message (stderr)

fish.cpp:16:41: error: expected ',' or '...' before 'X'
   16 | int64_t max_weights(int N, int M, int[] X, int[] Y, int[] W) {
      |                                         ^
fish.cpp: In function 'int64_t max_weights(int, int, int*)':
fish.cpp:18:14: error: 'm' was not declared in this scope
   18 |     fore(i,0,m) {
      |              ^
fish.cpp:5:47: note: in definition of macro 'fore'
    5 | #define fore(i, l, r) for(int i=int(l); i<int(r); i++)
      |                                               ^
fish.cpp:19:12: error: 'x' was not declared in this scope
   19 |         if(x[i] % 2)
      |            ^
fish.cpp:21:12: error: 'x' was not declared in this scope
   21 |         if(x[i] > 1)
      |            ^
fish.cpp:26:18: error: 'm' was not declared in this scope
   26 |         fore(i,0,m)
      |                  ^
fish.cpp:5:47: note: in definition of macro 'fore'
    5 | #define fore(i, l, r) for(int i=int(l); i<int(r); i++)
      |                                               ^
fish.cpp:27:18: error: 'w' was not declared in this scope
   27 |             ans+=w[i];
      |                  ^
fish.cpp:30:18: error: 'm' was not declared in this scope
   30 |         fore(i,0,m) {
      |                  ^
fish.cpp:5:47: note: in definition of macro 'fore'
    5 | #define fore(i, l, r) for(int i=int(l); i<int(r); i++)
      |                                               ^
fish.cpp:31:16: error: 'x' was not declared in this scope
   31 |             if(x[i] == 0)
      |                ^
fish.cpp:32:23: error: 'w' was not declared in this scope
   32 |                 sum1+=w[i];
      |                       ^
fish.cpp:34:23: error: 'w' was not declared in this scope
   34 |                 sum2+=w[i];
      |                       ^
fish.cpp:38:20: error: 'n' was not declared in this scope
   38 |         int64_t dp[n+5];
      |                    ^
fish.cpp:39:16: error: 'dp' was not declared in this scope
   39 |         memset(dp,0,sizeof dp);
      |                ^~
fish.cpp:41:16: error: 'grid' was not declared in this scope
   41 |         memset(grid,0,sizeof grid);
      |                ^~~~
fish.cpp:42:18: error: 'm' was not declared in this scope
   42 |         fore(i,0,m)
      |                  ^
fish.cpp:5:47: note: in definition of macro 'fore'
    5 | #define fore(i, l, r) for(int i=int(l); i<int(r); i++)
      |                                               ^
fish.cpp:43:18: error: 'x' was not declared in this scope
   43 |             grid[x[i]] = w[i];
      |                  ^
fish.cpp:43:26: error: 'w' was not declared in this scope
   43 |             grid[x[i]] = w[i];
      |                          ^