过样例,8pts求调
查看原帖
过样例,8pts求调
349824
WsW_花逝爆零人楼主2025/7/31 18:34

只过了样例#1

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
bool mp[1010][1010];
int dir[4][2]={0,1,1,0,0,-1,-1,0};
int n,ans;
int cnt(int x,int y){
    int c=0;
	for(int i=0;i<4;i++){
        c+=mp[x+dir[i][0]][y+dir[i][1]];
    }
    return c;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	while(n--){
		int x,y; cin>>x>>y;
		++x,++y;//防止越界
		mp[x][y]=1;
		if(cnt(x,y)==3)ans++;

		for(int i=0;i<4;i++){
			int xx=x+dir[i][0],yy=y+dir[i][1];
			if(cnt(xx,yy)==3)ans++;
			if(cnt(xx,yy)==4)ans--;
		}
		cout<<ans<<'\n';
	}
	return 0;
}
2025/7/31 18:34
加载中...