제출 #1002400

#제출 시각아이디문제언어결과실행 시간메모리
1002400overwatch9메기 농장 (IOI22_fish)C++17
컴파일 에러
0 ms0 KiB
// #include "fish.h" #include <bits/stdc++.h> using namespace std; using ll = long long; vector <vector <pair <int, ll>>> fish; vector <vector <ll>> pfx; int n, m; const int maxn = 1e5 + 1; ll dp[maxn][2][2]; bool ready[maxn][2][2]; ll cost(int i, bool l1, bool l2, bool l3) { if (i-1 >= 1 && !l2 && (l1 || l3)) return fish[i-1][1].second; return 0; } ll solve(int i, bool l1, bool l2) { if (i == n+1) { if (l1 && !l2) return fish[i-1][1].second; return 0; } if (ready[i][l1][l2]) return dp[i][l1][l2]; ll ans = solve(i+1, l2, false) + cost(i, l1, l2, false); ll ans2 = solve(i+1, l2, true) + cost(i, l1, l2, true); ready[i][l1][l2] = true; dp[i][l1][l2] = max(ans, ans2); return max(ans, ans2); } ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) { n = N; m = M; fish.resize(N+1); pfx.resize(N+1); for (int i = 0; i < M; i++) { fish[X[i] + 1].push_back({Y[i] + 1, W[i]}); } // dp = vector <vector <ll>> (N+1, vector <ll> (N+1, -1)); for (int i = 1; i <= N; i++) { fish[i].push_back({0, 0}); sort(fish[i].begin(), fish[i].end()); pfx[i].resize((int)fish[i].size() + 5, 1e18); for (int j = 1; j < (int)fish[i].size(); j++) pfx[i][j] = pfx[i][j-1] + fish[i][j].second; } return solve(1, false, false); } int main() { int nn, mm; cin >> nn >> mm; vector <int> x(mm), y(mm), w(mm); for (int i = 0; i < mm; i++) cin >> x[i] >> y[i] >> w[i]; cout << max_weights(nn, mm, x, y, w) << '\n'; }

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/cclpXYkn.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccoTO9An.o:fish.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status