Submission #728796

#TimeUsernameProblemLanguageResultExecution timeMemory
728796kwongwengCatfish Farm (IOI22_fish)C++17
Compilation error
0 ms0 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef long double ld; typedef pair<ll, ll> pll; #define FOR(i, a, b) for(int i = a; i < b; i++) #define ROF(i, a, b) for(int i = a; i >= b; i--) #define ms memset #define pb push_back #define fi first #define se second // O(n^2) dp ll max_weights(int n, int m, vi X, vi Y, vi W){ ll mat[n][n]; //position of all fishes ms(mat, 0, sizeof(mat)); FOR(i,0,m){ mat[X[i]][Y[i]] = W[i]; } ll dp[n][n][2]; // dp[i][j][0] - mat[i][j] chosen, while increasing // dp[i][j][1] - while decreasing ms(dp,0,sizeof(dp)); FOR(i,0,n){ //decreasing if (i > 0){ FOR(k,0,i-1){ dp[i][n-1][1] = max(dp[i][n-1][1], dp[k][n-1][0]); } dp[i][n-1][1] += mat[i][n-1]; ROF(j,n-2,0){ dp[i][j][1] = max(dp[i][j][1], dp[i][j+1][1]); dp[i][j][1] = max(dp[i][j][1], dp[i-1][j+1][1]); dp[i][j][1] += mat[i][j]; } } if (i < n-1){ //increasing if (i>1) dp[i][0][0] = max(dp[i][0][0], dp[i-1][0][1]); if (i>2) dp[i][0][0] = max(dp[i][0][0], dp[i-2][n-1][0]); dp[i][0][0] += mat[i][0]; FOR(j,1,n){ dp[i][j][0] = max(dp[i][j][0], dp[i][j-1][0]); if (i>0){ dp[i][j][0] = max(dp[i][j][0], dp[i-1][j-1][0]); } dp[i][j][0] += mat[i][j]; } } ll ans = 0; FOR(i,0,n){ FOR(j,0,n){ ans = max(ans, max(dp[i][j][0], dp[i][j][1])); } } if (n > 2){ ll val = 0; FOR(i,0,n){ val += mat[n-1][i]; } ans = max(ans, dp[n-3][0][1] + val); } return ans; }

Compilation message (stderr)

fish.cpp: In function 'll max_weights(int, int, vi, vi, vi)':
fish.cpp:71:1: error: expected '}' at end of input
   71 | }
      | ^
fish.cpp:20:47: note: to match this '{'
   20 | ll max_weights(int n, int m, vi X, vi Y, vi W){
      |                                               ^
fish.cpp:71:1: warning: control reaches end of non-void function [-Wreturn-type]
   71 | }
      | ^