답안 #859569

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
859569 2023-10-10T10:22:05 Z kim 메기 농장 (IOI22_fish) C++17
컴파일 오류
0 ms 0 KB
#include "fish.h"

#include <cassert>
#include <cstdio>

#include <vector>

#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define int ll
#define pb push_back
#define pii pair<int,int>
#define f first
#define s second

struct A{
    int x,y,w;
    A(int x_,int y_,int w_):x(x_),y(y_),w(w_){}

    static bool cmpX(const A&l,const A&r){
        if(l.x==r.x) return l.y<r.y;
        return l.x<r.x;
    }
    static bool cmpY(const A&l,const A&r){
        if(l.y==r.y) return l.x<r.x;
        return l.y<r.y;
    }

};

vector<A> fish;
ll dp1[305][305],dp2[305][305],dp0[305][305];
ll n,m;
vector<pair<ll,ll>> fx[100005],fy[100005];
ll arr[305][305];

ll max_weights(int N,int M,vector<int> X,vector<int> Y,vector<int> W) {
    n=N;
    m=M;
    for(int i=0;i<M;++i){
        ++X[i],++Y[i];
    }
    for(int i=0;i<M;++i){
        fish.emplace_back(X[i],Y[i],W[i]);
        fx[X[i]].emplace_back(Y[i],W[i]);
        fy[Y[i]].emplace_back(X[i],W[i]);
        arr[X[i]][Y[i]]=W[i];
    }
    sort(fish.begin(),fish.end(),A::cmpY);

    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            dp0[i][j]=arr[i][j]+dp0[i][j-1];
        }
    }
    for(int i=1;i<=n;++i){
        for(int j=0;j<=n;++j){
            for(int k=0;k<=n;++k){
                if(k==j){
                    dp1[i][j]=max(dp1[i][j],dp1[i-1][k]);
                }
                else if(k<j){
                    dp1[i][j]=max(dp1[i][j],dp1[i-1][k]+dp0[i-1][j]-dp0[i-1][k]);
                }
                else{
                    dp1[i][j]=max(dp1[i][j],dp1[i-1][k]+dp0[i][k]-dp0[i][j]);
                }
            }
        }
    }
    ll ans=0;
    for(int j=0;j<=n;++j) ans=max(ans,dp1[n][j]);

    return ans;
}



int main() {
  int N, M;
  assert(2 == scanf("%d %d", &N, &M));

  std::vector<int> X(M), Y(M), W(M);
  for (int i = 0; i < M; ++i) {
    assert(3 == scanf("%d %d %d", &X[i], &Y[i], &W[i]));
  }

  long long result = max_weights(N, M, X, Y, W);
  printf("%lld\n", result);
  return 0;
}

Compilation message

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