标签:nbsp main else bsp namespace algo int fine print
#include <stdio.h> #include <iostream> #include <stack> #include <vector> #include <math.h> #include <algorithm> #include <set> #include <queue> using namespace std; #define LL long long const int maxn=2e5+1; int meow[2][2][2]; int x[maxn],y[maxn]; int main() { freopen("in.txt","r",stdin); int n; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d%d",x+i,y+i); for(int i=0;i<n;i++) { x[i]=(x[i]%2+2)&1; y[i]=(y[i]%2+2)&1; } x[n]=x[0],y[n]=y[0]; int area=0; LL ans=0; for(int i=1;i<=n;i++) { area^=(x[i]&y[i-1])^(x[i-1]&y[i]); for(int tx=0;tx<2;tx++) for(int ty=0;ty<2;ty++) { int t=(tx&y[i])^(ty&x[i]); ans+=meow[area^t][tx][ty]; } ans--; meow[area][x[i]][y[i]]++; } if(area) printf("0\n"); else cout<<ans<<endl; return 0; }
Gym 101142 I.Integral Polygons 计算几何 奇偶性 前缀和
标签:nbsp main else bsp namespace algo int fine print
原文地址:https://www.cnblogs.com/polya/p/9693990.html