제출 #760951

#제출 시각아이디문제언어결과실행 시간메모리
760951drdilyorCatfish Farm (IOI22_fish)C++17
컴파일 에러
0 ms0 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; using ll = long long; ll max_weights( int n, int m, vector<int> x, vector<int> y, vector<int> w) { vector arr(n+1, vector(n+1, 0ll)); for (int i = 0; i < m; i++) arr[x[i]+1][y[i]] += w[i]; vector pref(n+1, vector(n+2, 0ll)); for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++) pref[i][j+1] = pref[i][j] + arr[i][j]; auto sum = [&](int c, int l, int r) { // [l, r) ll res = pref[c][r] - pref[c][l]; if (l <= r) return res; else return 0ll; }; vector memo(2, vector(n+1, vector(n+1, -1ll))); auto dp = [&](auto& dp, bool inc, int c, int h2)->ll{ if (c == n+1) return 0; ll& res = memo[inc][c][h2]; if (res!=-1) return res; res = 0; if (inc) { for (int h3 = h2; h3 <= n; h3++) { ll val = sum(c-1, h2, h3) + sum(c, h3, h2); res = max(res, val + dp(dp, true, c+1, h3)); res = max(res, val + dp(dp, false, c+1, h3)); } } else { for (int h3 = 0; h3 <= h2; h3++) { ll val = sum(c-1, h2, h3) + sum(c, h3, h2); res = max(res, val + dp(dp, false, c+1, h3)); } } res = max(res, dp(dp, true, c+1, 0)); return res; }; ll res = dp(dp, true, 1, 0); return res; }

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

fish.cpp: In function 'll max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:47:1: error: expected '}' at end of input
   47 | }
      | ^
fish.cpp:8:64: note: to match this '{'
    8 |     int n, int m, vector<int> x, vector<int> y, vector<int> w) {
      |                                                                ^
fish.cpp:9:37: warning: control reaches end of non-void function [-Wreturn-type]
    9 |     vector arr(n+1, vector(n+1, 0ll));
      |                                     ^