답안 #1072425

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1072425 2024-08-23T18:51:54 Z vjudge1 메기 농장 (IOI22_fish) C++17
14 / 100
46 ms 17388 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using ii = pair <ll, ll>;
using vii = vector <ii>;
using vi = vector <int>;

// dp[i][j] = max grams caught if caught catfish until j from column i-1

// pier worth extending up to every catfish or until the end (O(n+m) optimal maximal piers)

const ll MAXN = 3E2+16, INF = ll(1E18)+16;
ll dp[MAXN][10][10];
vii ccs[MAXN];
ll max_weights (int n, int m, vi vx, vi vy, vi vw) {
    for (ll i = 0; i < m; i++)
        ccs[vx[i]].push_back({ vy[i]+1, vw[i] });
    for (ll x = 0; x < n; x++) {
        sort(ccs[x].begin(), ccs[x].end());
        ccs[x].insert(ccs[x].begin(), ii{ -1, 0 });
        // ps[x].push_back(0);
        ll acc = 0;
        for (auto &[y, w] : ccs[x]) {
            acc += w;
            w = acc;
        }
    }
    auto fget = [&](ll x, ll y) -> ll { // pier at column x up until y
        // ll ans = 0;
        if (x < 0 || n <= x) return 0;
        // assert(upper_bound(ccs[x].begin(), ccs[x].end(), ii{ y, INF })-1 != ccs[x].end());
        return (upper_bound(ccs[x].begin(), ccs[x].end(), ii{ y, INF })-1)->second;
        // if ()
    };
    // auto ffix = [&](ll x1, ll y1, ll x2, ll y2) -> ll { // fix the combination of those dps
    //     assert(x1 < x2);
    //     if (x1+2 < x2) return 0;
    //     if (x1+2 == x2) {
    //         return fget(x1+1, min(y1, y2));
    //     }
    //     if (x1+1 == x2) {
    //         return fget(x1, min(y1, y2)) + fget(x2, min(y1, y2));
    //     }
    //     assert(false);
    // };
    auto finc = [&](ll x, ll y1, ll y2, ll y3) -> ll { // fix the combination of those dps
        ll unav = max(y1, y2);
        // fget(x-2, y1)
        // fget(x-1, y2)
        if (y3 > unav) return fget(x-1, y3) - fget(x-1, unav) + fget(x+1, y3) - fget(x, min(y2, y3));
        return fget(x+1, y3) - fget(x, min(y2, y3));
    };
    ll ans = 0;
    for (ll x = 0; x < n; x++) {
        for (ll y1 = 0; y1 <= 9; y1++) {
            for (ll y2 = 0; y2 <= 9; y2++) {
                for (ll y3 = 0; y3 <= 9; y3++) {
                    dp[x][y2][y3] = max(dp[x][y2][y3], (x?dp[x-1][y1][y2]:0) + finc(x, y1, y2, y3));
                    ans = max(ans, dp[x][y2][y3]);
                }
            }
            // ll ra = /* fget(x-1, y) +  */fget(x+1, y);
            // dp[x][y][0] = ra;
            // dp[x][y][0] = ra;
            // if (x == 0) { dp[x][0][y] = ra; continue; }
            // for (ll y2 = 0; y2 <= 9; y2++) {
            //     ll &ans = dp[x][y2][y];
            //     for (ll y3 = 0; y3 <= 9; y3++) {
            //         ;
            //     }
            //     // if (dp[x2][y2]+ra-ffix(x2, y2, x, y) == 11) cerr << "  " << x2 << ' ' << y2 << '\n';
            //     dp[x][y] = max(dp[x][y], dp[x2][y2] + ra - ffix(x2, y2, x, y));
            // }
            
            // for (ll x2 = x-1; x2 < x; x2++) {
            //     for (ll y2 = 0; y2 <= n; y2++) {
            //         dp[x][y] = max(dp[x][y], dp[x2][y2] + ra - ffix(x2, y2, x, y));
            //     }
            // }
            // cerr << x << ' ' << y << ":  ";
            // for (ll x2 = max(0LL, x-3); x2 < x; x2++) {
            // }
            // cerr << dp[x][y] << '\n';
        }
        // cerr << '\n';
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 26 ms 9408 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 46 ms 17388 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1628 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 6 ms 860 KB Output is correct
11 Correct 4 ms 604 KB Output is correct
12 Correct 7 ms 724 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 6 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 6 ms 860 KB Output is correct
11 Correct 4 ms 604 KB Output is correct
12 Correct 7 ms 724 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 6 ms 600 KB Output is correct
15 Incorrect 4 ms 604 KB 1st lines differ - on the 1st token, expected: '299', found: '9'
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 6 ms 860 KB Output is correct
11 Correct 4 ms 604 KB Output is correct
12 Correct 7 ms 724 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 6 ms 600 KB Output is correct
15 Incorrect 4 ms 604 KB 1st lines differ - on the 1st token, expected: '299', found: '9'
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1628 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 26 ms 9408 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -