Submission #904151

# Submission time Handle Problem Language Result Execution time Memory
904151 2024-01-11T20:37:40 Z dsyz Furniture (JOI20_furniture) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAXN (1005)
ll N,M;
ll cnt[2 * MAXN];
bool R[MAXN][MAXN];
void del(ll i, ll j){
    if(R[i][j] == 1 || cnt[i + j] == 1) return;
    cnt[i + j]--;
    R[i][j] = 1;
    if(i + 1 < N && (j == 0 || R[i + 1][j - 1] == 1)) del(i + 1,j);
    if(i - 1 >= 0 && (j == M - 1 || R[i - 1][j + 1] == 1)) del(i - 1,j);
    if(j + 1 < M && (i == 0 || R[i - 1][j + 1] == 1)) del(i,j + 1);
    if(j - 1 >= 0 && (i == M - 1 || R[i + 1][j - 1] == 1)) del(i,j - 1);
}
int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin>>N>>M;
	for(ll i = 0;i < N;i++){
		for(ll j = 0;j < M;j++){
			cin>>R[i][j];
			cnt[i + j]++;
			if(R[i][j] == 1){
				del(i,j);
			}
		}
	}
	ll Q;
	cin>>Q;
	for(ll i = 0;i < Q;i++){
		ll A,B;
		cin>>A>>B;
		A--, B--;
		del(A,B);
		if(R[A][B]){
			cout<<0<<'\n';
		}else{
			cout<<1<<'\n';
		}
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -