taikula
2024-01-10 19:52:39
发布于:广东
1阅读
0回复
0点赞
#include <iostream>
#include <cstdio>
using namespace std;
bool map[1100][1100];
int dxy[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
bool check(int x, int y){
if(map[x][y] == 0){
return false;
}
int point = 0;
for(int i = 0; i < 4; i++){
if(map[x + dxy[i][0]][y + dxy[i][1]] && x + dxy[i][0] >= 0 && x + dxy[i][0] <= 1000 && y + dxy[i][1] >= 0 && y + dxy[i][1] <= 1000){
point++;
}
}
return point == 3 ? true : false;
}
int main(){
int n;
cin >> n;
int ans = 0;
for(int i = 1; i <= n; i++){
int x, y;
cin >> x >> y;
for(int j = 0; j < 4; j++){
if(check(x + dxy[j][0], y + dxy[j][1])){
map[x][y] = 1;
if(check(x + dxy[j][0], y + dxy[j][1])){
map[x][y] = 0;
}else{
ans--;
map[x][y] = 0;
}
}else{
map[x][y] = 1;
if(check(x + dxy[j][0], y + dxy[j][1])){
ans++;
map[x][y] = 0;
}else{
map[x][y] = 0;
}
}
}
map[x][y] = 1;
if(check(x, y)){
ans++;
}
cout << ans << endl;
}
return 0;
}
这里空空如也
有帮助,赞一个