# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
172319 | ho94949 | 유괴 2 (JOI17_abduction2) | C++17 | 199 ms | 65028 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<bits/stdc++.h>
using namespace std;
enum {UP, LEFT, DOWN, RIGHT};
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
const int MAXN = 2020;
int H, W, Q;
int A[MAXN], B[MAXN];
int dp[MAXN][MAXN][4];
bool ins(int x, int y){ return 0<=x&&x<H&&0<=y&&y<W; }
int solve(int x, int y, int d)
{
if(dp[x][y][d] != -1) return dp[x][y][d];
int nx = x+dx[d], ny = y+dy[d];
if(!ins(nx, ny)) return dp[x][y][d] = 0;
if(d==UP||d==DOWN)
{
if(A[nx]<B[ny]) return dp[x][y][d] = 1+solve(nx, ny, d);
else return dp[x][y][d] = 1+max(solve(nx, ny, LEFT), solve(nx, ny, RIGHT));
}
else
{
if(B[ny]<A[nx]) return dp[x][y][d] = 1+solve(nx, ny, d);
else return dp[x][y][d] = 1+max(solve(nx, ny, UP), solve(nx, ny, DOWN));
}
}
int main()
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... |