题解:P10703 [SNCPC2024] 窗花
1.思路
考虑使用一个变量 double 类型)
一张窗花的中心在
-
-
-
如果以上两种都不符合,那么就会新覆盖
2 的面积,ans \gets ans+2 。
2.代码
#include<bits/stdc++.h>
using namespace std;
int n,mp[114][514];
double cnt;
signed main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
while(n--)
{
int x,y;
cin>>x>>y;
if(mp[x][y]) continue;
cnt += 2.0000000000000000;
mp[x][y]++;
cnt -= 0.500000000 * (double)(mp[x - 1][y] + mp[x + 1][y] + mp[x][y - 1] + mp[x][y + 1]);
}
cout<<cnt;
return 0;
}