# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
292911 | arnold518 | Furniture (JOI20_furniture) | C++14 | 936 ms | 38068 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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 2000;
int N, M, Q, A[MAXN+10][MAXN+10];
int dp1[MAXN+10][MAXN+10], dp2[MAXN+10][MAXN+10];
int S[MAXN+10][MAXN+10], C[MAXN+10];
int main()
{
scanf("%d%d", &N, &M);
for(int i=1; i<=N; i++) for(int j=1; j<=M; j++) scanf("%d", &A[i][j]);
for(int i=1; i<=N; i++) for(int j=1; j<=M; j++)
{
if(i==1 && j==1) dp1[i][j]=1;
else if(A[i][j]) dp1[i][j]=0;
else dp1[i][j]=dp1[i-1][j]|dp1[i][j-1];
}
for(int i=N; i>=1; i--) for(int j=M; j>=1; j--)
{
if(i==N && j==M) dp2[i][j]=1;
else if(A[i][j]) dp2[i][j]=0;
else dp2[i][j]=dp2[i+1][j]|dp2[i][j+1];
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |