답안 #838727

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
838727 2023-08-27T16:14:42 Z Andrey 메기 농장 (IOI22_fish) C++17
컴파일 오류
0 ms 0 KB
#include "fish.h"
#include<bits/stdc++.h>
#include <vector>
using namespace std;

long long haha[5000][5000];
long long dp[3001][3001][3];

long long max_weights(int n, int m, std::vector<int> x, std::vector<int> y, std::vector<int> w) {
    for(long long i = 0; i <= n; i++) {
        for(long long j = 0; j <= n; j++) {
            haha[i][j] = 0;
        }
    }
    for(long long i = 0; i < m; i++) {
        haha[x[i]][y[i]+1] = w[i];
    }
    for(long long i = 0; i < n; i++) {
        for(long long j = 1; j <= n; j++) {
            haha[i][j]+=haha[i][j-1];
        }
    }
    for(long long i = 0; i <= n; i++) {
        for(long long j = 0; j <= n; j++) {
            dp[i][j][0] = 0;
            dp[i][j][1] = 0;
            dp[i][j][2] = 0;
        }
    }
    for(int i = 0; i <= n; i++) {
        dp[0][i][0] = haha[1][i];
    }
    long long ans = 0,sb;
    for(long long i = 1; i < n; i++) {
        sb = 0;
        for(long long j = 0; j <= n; j++) {
            dp[i][j][2] = max(dp[i][j][2],dp[i-1][j][0]);
            dp[i][j][2] = max(dp[i][j][2],dp[i-1][j][1]);
            sb = max(sb,dp[i-1][j][2]);
        }
        long long big = 0,big = 0;
        for(long long j = 0; j <= n; j++) {
            big = max(big,dp[i-1][j][0]-haha[i-1][j]);
            dp[i][j][0] = big+haha[i+1][j]+haha[i-1][j]-haha[i][j];
        }
        big = 0;
        for(long long j = n; j >= 0; j--) {
            dp[i][j][1] = big-haha[i][j]+haha[i+1][j];
            big = max(big,dp[i-1][j][0]);
        }
        big = 0;
        for(long long j = n; j >= 0; j--) {
            dp[i][j][1] = max(dp[i][j][1],big-haha[i][j]+haha[i+1][j]);
            big = max(big,dp[i-1][j][1]);
        }
        for(long long j = 0; j <= n; j++) {
            dp[i][j][0] = max(dp[i][j][0],sb+haha[i+1][j]);
        }
    }
    for(long long i = 0; i <= n; i++) {
        ans = max(ans,dp[n-1][i][0]);
        ans = max(ans,dp[n-1][i][1]);
        ans = max(ans,dp[n-1][i][2]);
    }
    return ans;
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:41:27: error: redeclaration of 'long long int big'
   41 |         long long big = 0,big = 0;
      |                           ^~~
fish.cpp:41:19: note: 'long long int big' previously declared here
   41 |         long long big = 0,big = 0;
      |                   ^~~