제출 #701311

#제출 시각아이디문제언어결과실행 시간메모리
701311n1kCatfish Farm (IOI22_fish)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define vt vector #define pb push_back #define ar array #define all(x) (x).begin(), (x).end() #define sz(x) (x).size() using namespace std; /* ## TAKE IT EASY ## 1. simplify 2. add new elements 3. brute force solution 4. optimize 5. start implementing */ // --- templates --- // --- code --- const int N = 300 + 5; ll dp[N][N][N]; ll max_weights(int n, int m, vt<int> X, vt<int> Y, vt<int> W){ memset(dp, 0, sizeof dp); int h = n + 1; vt<vt<ll>> a(n + 5, vt<ll>(h)); for(int i = 0; i < m; i++){ a[X[i]][Y[i] + 1] = W[i]; } for(int i = 0; i < n; i++){ for(int j = 1; j < h; j++){ a[i][j] += a[i][j - 1]; } } for(int i = 0; i < n; i++){ for(int h1 = 0; h1 < h; h1++){ for(int h2 = 0; h2 < h; h2++){ for(int h3 = 0; h3 < h; h3++){ ll l = 0, r = a[i + 1][h3], sub = a[i][min(h2, h3)]; if(i == 0){ dp[i][h2][h3] = max(dp[i][h2][h3], r); }else{ l = max((ll)0, a[i - 1][h3] - a[i - 1][max(h1, h2)]); dp[i][h2][h3] = max(dp[i][h2][h3], l + dp[i - 1][h1][h2] + r - sub); } } } } } ll ans = 0; for(int h2 = 0; h2 < h; h2++){ for(int h3 = 0; h3 < h; h3++){ ans = max(ans, dp[n - 1][h2][h3]); } } return ans; } int main(){ int n, m; cin >> n >> m; vt<int> x(m), y(m), w(m); for(int i = 0; i < m; i++){ cin >> x[i] >> y[i] >> w[i]; } cout << max_weights(n, m, x, y, w) << endl; return 0; }

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

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