답안 #831524

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
831524 2023-08-20T10:09:51 Z MrDeboo 메기 농장 (IOI22_fish) C++17
컴파일 오류
0 ms 0 KB
#include "fish.h"
#include "bits/stdc++.h"
#define int long long
using namespace std;
map<pair<int,pair<int,int>>,int>dp;
int vct[311][311];
int vctt[311][311];
vector<int>v[311];
int N;
int slv(int a,int b,int c){
    if(a==N)return 0;
    if(mp.count({a,{b,c}}))return mp[{a,{b,c}}];
    // cerr<<a<<' '<<b<<endl;
    int mx=0;
    int tot=0;
    for(auto &i:v[a]){
        if(i<=b)tot-=vct[a][i];
        if(i>max(b,c))tot+=vct[a-1][i];
        tot+=vct[a+1][i];
        mx=max(mx,slv(a+1,i,b)+tot);
    }
    return mp[{a,{b,c}}]=mx;
}
long long max_weights(int32_t n, int32_t m, std::vector<int32_t> x, std::vector<int32_t> y, std::vector<int32_t> w) {
    N=n;
    if(n>300){
        int g=0;
        for(auto &i:w)g+=i;
        return g;
    }
    memset(dp,-1,sizeof dp);
    for(int i=0;i<=n;i++)v[i].push_back(0);
    for(int i=0;i<m;i++){
        vct[x[i]][y[i]+1]=w[i];
        if(x[i])v[x[i]-1].push_back(y[i]+1);
        v[x[i]].push_back(y[i]+1);
        v[x[i]+1].push_back(y[i]+1);
    }
    for(int i=0;i<=n;i++)sort(v[i].begin(),v[i].end());
    for(int i=0;i<=n;i++)v[i].resize(unique(v[i].begin(),v[i].end())-v[i].begin());
    return slv(0,0,0);
}

Compilation message

fish.cpp: In function 'long long int slv(long long int, long long int, long long int)':
fish.cpp:12:8: error: 'mp' was not declared in this scope; did you mean 'dp'?
   12 |     if(mp.count({a,{b,c}}))return mp[{a,{b,c}}];
      |        ^~
      |        dp
fish.cpp:22:12: error: 'mp' was not declared in this scope; did you mean 'mx'?
   22 |     return mp[{a,{b,c}}]=mx;
      |            ^~
      |            mx
fish.cpp: In function 'long long int max_weights(int32_t, int32_t, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:31:12: error: cannot convert 'std::map<std::pair<long long int, std::pair<long long int, long long int> >, long long int>' to 'void*'
   31 |     memset(dp,-1,sizeof dp);
      |            ^~
      |            |
      |            std::map<std::pair<long long int, std::pair<long long int, long long int> >, long long int>
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++config.h:518,
                 from /usr/include/c++/10/bits/stl_algobase.h:59,
                 from /usr/include/c++/10/vector:60,
                 from fish.h:1,
                 from fish.cpp:1:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:1: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   59 | __NTH (memset (void *__dest, int __ch, size_t __len))
      | ^~~~~