Submission #825155

# Submission time Handle Problem Language Result Execution time Memory
825155 2023-08-14T14:53:56 Z PixelCat Radio Towers (IOI22_towers) C++17
Compilation error
0 ms 0 KB
#include "fish.h"

#ifdef NYAOWO
#include "grader.cpp"
#endif

#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i, a, b) for(int i = a; i >= b; i--)
#define F first
#define S second 
#define all(x) x.begin(), x.end()
#define sz(x) ((int)x.size())
#define eb emplace_back
#define int LL
using namespace std;
using i32 = int32_t;
using LL = long long;
using pii = pair<int, int>;

inline void chmax(int &x, int val) { x = max(x, val); }

const int MAXN = 3000;
const int INF = 1e15;

int n, m;
int useful[MAXN + 10][MAXN + 10];
int pre[MAXN + 10][MAXN + 10];
int dp1[MAXN + 10][MAXN + 10];
int dp2[MAXN + 10][MAXN + 10];

long long max_weights(i32 N, i32 M, vector<i32> X, vector<i32> Y,
                      vector<i32> W) {
    n = N;
    m = M;

    memset(pre, 0, sizeof(pre));
    For(i, 0, m - 1) {
        X[i]++; Y[i]++;
        pre[X[i]][Y[i]] += W[i];
        const int dx[8] = {-1, 0, 0, 0, 1, 1, 1, 2};
        const int dy[8] = {0, -1, 0, 1, -1, 0, 1, 0};
        For(it, 0, 7) {
            useful[X[i] + dx[it]][Y[i] + dy[it]] = 1;
        }
    }
    For(i, 1, n) For(j, 1, n) {
        pre[i][j] += pre[i][j - 1];
    }

    For(i, 0, n + 1) For(j, 0, n + 1) {
        dp1[i][j] = dp2[i][j] = -INF;
    }
    dp2[0][0] = 0;

    For(i, 1, n + 1) {
        int mx = -INF;
        For(j, 1, n) {
            chmax(mx, dp1[i - 1][j] - pre[i - 1][j]);
            chmax(mx, dp2[i - 1][j] - pre[i - 1][j]);
            dp1[i][j] = dp2[i - 1][0] + pre[i - 1][j];
            if(useful[i][j]) {
                chmax(dp1[i][j], mx + pre[i - 1][j]);
            }
        }
        mx = -INF;
        Forr(j, n, 0) {
            chmax(mx, dp2[i - 1][j]);
            dp2[i][j] = dp1[i - 1][j] + pre[i][j];
            if(useful[i][j] || j == 0) {
                chmax(dp2[i][j], mx + pre[i][j] - pre[i - 1][j]);
            }
        }
    }

    int ans = 0;
    For(j, 0, n) chmax(ans, dp2[n + 1][j]);
    return ans;
}

/*

5 4
0 2 5
1 1 2
4 4 1
3 3 3

8

*/

Compilation message

towers.cpp:1:10: fatal error: fish.h: No such file or directory
    1 | #include "fish.h"
      |          ^~~~~~~~
compilation terminated.