Submission #1125327

#TimeUsernameProblemLanguageResultExecution timeMemory
1125327VVUUCatfish Farm (IOI22_fish)C++20
Compilation error
0 ms0 KiB
#include "fish.h" #include<bits/stdc++.h> #define int long long #define push_back emplace_back using namespace std; int max_weights(int N, int M, int X[], int Y[], int W[]){ for(int i=0; i<M; i++) X[i]++, Y[i]++; vector<vector<pair<int, int> > > p; vector<vector<int> > pre; p.resize(N+10); for(int i=0; i<=N; i++) p[i].push_back(make_pair(0, 0)); for(int i=0; i<M; i++) p[X[i]].push_back(make_pair(Y[i], W[i])); vector<int> ans; ans.resize(N+10); vector<vector<vector<int> > > dp; dp.resize(N+10); for(int i=1; i<=N; i++) for(int i=1; i<=N; i++) for(int i=1; i<=N; i++){ sort(p[i].begin(), p[i].end()); dp[i].resize(p[i].size(), vector<int>(5)); pre[i].resize(p[i].size()); for(int j=1; j<p[i].size(); j++) pre[i][j]+=pre[i][j-1]+p[i][j].second; } for(int i=2; i<=N; i++){ dp[i][0][0]=dp[i-1][0][0]; int L=p[i-1].size(); int val=dp[i-1][L][0]+pre[i].back(); for(int j=pre[i].size()-1; j>=0; j--){ while(L && p[i-1][L-1].first>p[i][j].first) L--, val=max(val, dp[i-1][L][0]+pre[i][j]); if(j) dp[i][j][3]=max(dp[i][j][3], val-pre[i][j-1]); else dp[i][j][3]=max(dp[i][j][3], val); } dp[i][0][0]=max(dp[i][0][0], dp[i][0][3]); int D=0; val=-1e18; for(int j=1; j<p[i].size(); j++){ dp[i][j][1]=dp[i-1][0][0]; while(D+1<p[i-1].size() && p[i-1][D+1].first<p[i][j].first){ D++; val=max(val, dp[i-1][D][2]-pre[i-1][D-1]); } dp[i][j][2]=max(dp[i][j][2], max(val, ans[i-2])+pre[i-1][D]); } ans[i]=dp[i][0][0]; for(int j=1; j<p[i].size(); j++){ dp[i][j][0]=max(dp[i][j][1], max(dp[i][j][2], dp[i][j][3])); ans[i]=max(ans[i], dp[i][j][0]); } } return ans[N]; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccIspGiZ.o: in function `main':
grader.cpp:(.text.startup+0x267): undefined reference to `max_weights(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status