# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
877900 | konber | T-Covering (eJOI19_covering) | C++14 | 65 ms | 10380 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 <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
vector<vector<int>> a, grid;
vector<pair<int, int>> sp;
int K, N, M;
int memo[5003][5];
int dp(int i, int prev){
if(i==K) return 0;
if(memo[i][prev] != -1) return memo[i][prev];
int s1=-1, s2=-1, s3=-1, s4=-1;
int x=sp[i].first, y=sp[i].second;
int k=sp[i-1].first, j=sp[i-1].second;
if(prev==1){
grid[k][j]=grid[k-1][j]=grid[k+1][j]=grid[k][j-1]=1;
if(x-1>=0 && x+1<M && y-1>=0 && grid[x-1][y]+grid[x+1][y]+grid[x][y-1]==0){
int p=dp(i+1, 1);
if(p != -1)
s1 = a[x][y]+a[x-1][y]+a[x+1][y]+a[x][y-1]+p;
}
if(x-1>=0 && x+1<M && y+1<N && grid[x-1][y]+grid[x+1][y]+grid[x][y+1]==0){
int p=dp(i+1, 2);
if(p!=-1)
s2 = a[x][y]+a[x-1][y]+a[x+1][y]+a[x][y+1]+p;
}
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |