# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
680281 | mjhmjh1104 | Tortoise (CEOI21_tortoise) | C++17 | 200 ms | 444556 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
int n, a[500006], dist[500006], res, dp[306][606][306][2];
vector<int> playgrounds;
int pv[500006], nx[500006];
int f(int x, int y, int z, int w) {
if (y > 2 * n - 2) return 0;
if (dp[x][y][z][w] + 1) return dp[x][y][z][w];
if (w && a[x] == -1) return dp[x][y][z][w] = f(x, y, z, 0);
dp[x][y][z][w] = 0;
if (w && a[x] != -1) dp[x][y][z][w] = max(dp[x][y][z][w], f(x + 1, y - 1, min(n, max(a[x + 1], 0)), 1));
if (x < n - 1) dp[x][y][z][w] = max(dp[x][y][z][w], f(x + 1, y + 1, min(n, max(a[x + 1], 0)), 0));
if (pv[x] != -1 && z > 0 && y <= 2 * x) {
int dist = x - pv[x];
dp[x][y][z][w] = max(dp[x][y][z][w], f(x, y + 2 * dist, z - 1, 0) + 1);
}
if (nx[x] != -1 && z > 0 && y <= 2 * x) {
int dist = nx[x] - x;
dp[x][y][z][w] = max(dp[x][y][z][w], f(x, y + 2 * dist, z - 1, 1) + 1);
}
return dp[x][y][z][w];
}
int main() {
memset(dp, -1, sizeof dp);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |