Submission #955341

# Submission time Handle Problem Language Result Execution time Memory
955341 2024-03-30T07:42:36 Z Gray Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
// #include <bits/stdc++.h>

// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2,fma")
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>

#define M_PI 3.14159265358979323846
#define ll long long
using ld = double;
#define ff first
#define ss second
#define ln "\n"
#define gcd(x,y) __gcd(x,y)
using namespace std;

// const ll MOD = 1e9+7;
const ll INF = 2e18;
// const ll MAXN = 1e6+1;

ll max_weights(ll n, ll m, vector<ll> cx, vector<ll> cy, vector<ll> cw){
    n++;
    vector<pair<pair<ll, ll>, ll>> fish(m);
    for (ll i=0; i<m; i++){
        fish[i] = {{cx[i], cy[i]+1}, cw[i]};
    }
    sort(fish.begin(), fish.end(), [](auto op1, auto op2)->bool{
        return op1.ff.ss<op2.ff.ss;
    });
    vector<vector<ll>> A(n, vector<ll>(n));
    for (ll i=0; i<m; i++){
        A[fish[i].ff.ff][fish[i].ff.ss]=fish[i].ss;
    }
    vector<vector<ll>> pref(n, vector<ll>(n,0));
    for (ll i=0; i<n; i++){
        for (ll j=0; j<n; j++){
            pref[i][j] = (j==0?A[i][j]:pref[i][j-1]+A[i][j]);
        }
    }
    // return 0;
    vector<vector<vector<ll>>> dp(n, vector<vector<ll>>(n, vector<ll>(n, 0)));
    for (ll i=1; i<n; i++){
        for (ll j=0; j<n; j++){
            for (ll k=0; k<n; k++){
                if (j>k){
                    dp[i][j][k] = max(dp[i-1][k][n-1], dp[i-1][k][k]+pref[i-1][n-1]-pref[i-1][k]);
                }else dp[i][j][k] = dp[i-1][k][n-1]+pref[i][k]-pref[i][j];
                if (k)dp[i][j][k]=max(dp[i][j][k-1], dp[i][j][k]);
            }
        }
    }
    ll mx = 0;
    for (ll i=0; i<n; i++){
        mx = max(mx, dp[n-1][i][n-1]);
    }
    return mx;
}

// int main(){
//  ios_base::sync_with_stdio(false);
//  cin.tie(NULL);
//  ll t=1;
//  cin >> t;
//  // while (t--) solve();
// }


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

//   std::vector<long long> X(M), Y(M), W(M);
//   for (long long i = 0; i < M; ++i) {
//     assert(3 == scanf("%lld %lld %lld", &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/ccS0WIMW.o: in function `main':
grader.cpp:(.text.startup+0x25e): undefined reference to `max_weights(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status