Submission #1079187

# Submission time Handle Problem Language Result Execution time Memory
1079187 2024-08-28T11:48:01 Z vjudge1 Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#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

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: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:27:18: error: 'W' was not declared in this scope
   27 |             ans+=W[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: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];
      |                          ^
fish.cpp:51:18: error: 'n' was not declared in this scope
   51 |         ans = dp[n-1];
      |                  ^