제출 #1255499

#제출 시각아이디문제언어결과실행 시간메모리
1255499ebrambillFurniture (JOI20_furniture)C++17
5 / 100
5093 ms5316 KiB
//In the name of GOD

#include <bits/stdc++.h>
using namespace std;

const int maxN=1e3+5;
int n, m, q, dp[maxN][maxN];
bool c[maxN][maxN];

int main(){
	cin >>n >>m;
	for (int i=1; i<=n; i++)
		for (int j=1; j<=m; j++)
			cin >>c[i][j];
	cin >>q;
	while(q--){
		int x, y;
		cin >>x >>y;
		
		c[x][y]=true;
		dp[n][m]=1;
		for (int i=n; i>=1; i--)
			for (int j=m; j>=1; j--)
				if(i!=n or j!=m) dp[i][j]=(c[i][j] ? 0 : dp[i+1][j]+dp[i][j+1]);
		if(dp[1][1]==0){
			cout <<"0\n";
			c[x][y]=false;
		}
		else cout <<"1\n";
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...