Submission #1079188

# Submission time Handle Problem Language Result Execution time Memory
1079188 2024-08-28T11:49:31 Z vjudge1 Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#include "fish.h"

#include <bits/stdc++.h>

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
                      std::vector<int> W) {
  long long ok=1,ok1=1;
    fore(i,0,M) {
        if(X[i] % 2)
            ok=0;
        if(X[i] > 1)
            ok1=0;
    }
    long long ans=0;
    if(ok)
        fore(i,0,M)
            ans+=W[i];
    else if(ok1) {
        long long sum1=0,sum2=0;
        fore(i,0,M) {
            if(X[i] == 0)
                sum1+=W[i];
            else
                sum2+=W[i];
        }
        ans = max(sum1,sum2);
    } else {
        long long dp[N+5];
        memset(dp,0,sizeof dp);
        long long 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;
  return 0;
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:8:10: error: 'i' was not declared in this scope
    8 |     fore(i,0,M) {
      |          ^
fish.cpp:8:5: error: 'fore' was not declared in this scope
    8 |     fore(i,0,M) {
      |     ^~~~
fish.cpp:26:15: error: 'max' was not declared in this scope; did you mean 'std::max'?
   26 |         ans = max(sum1,sum2);
      |               ^~~
      |               std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from fish.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
fish.cpp:41:18: error: 'n' was not declared in this scope
   41 |         ans = dp[n-1];
      |                  ^