# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
292584 | Pajaraja | Furniture (JOI20_furniture) | C++17 | 3428 ms | 5496 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define MAXN 1007
using namespace std;
bool dpgl[MAXN][MAXN],dpdd[MAXN][MAXN],b[MAXN][MAXN];
int d[2*MAXN];
int n,m;
void theboysgl(int x,int y)
{
if(x==n+1 || y==m+1 || !dpgl[x][y] || !((x==1 || !dpgl[x-1][y]) && (y==1 || !dpgl[x][y-1]))) return;
if(dpdd[x][y]) d[x+y]--;
dpgl[x][y]=false;
theboysgl(x+1,y); theboysgl(x,y+1);
}
void theboysdd(int x,int y)
{
if(x==0 || y==0 || !dpdd[x][y] || !((x==n || !dpdd[x+1][y]) && (y==m || !dpdd[x][y+1]))) return;
if(dpgl[x][y]) d[x+y]--;
dpdd[x][y]=false;
theboysdd(x-1,y); theboysdd(x,y-1);
}
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin>>b[i][j];
dpgl[1][1]=true; dpdd[n][m]=1;
for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if((i!=1 || j!=1) && !b[i][j]) dpgl[i][j]=dpgl[i-1][j] || dpgl[i][j-1];
for(int i=n;i>=1;i--) for(int j=m;j>=1;j--) if((i!=n || j!=m) && !b[i][j]) dpdd[i][j]=dpdd[i+1][j] || dpdd[i][j+1];
for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(dpgl[i][j] && dpdd[i][j]) d[i+j]++;
int q; cin>>q;
while(q--)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |