2016-2017 ACM-ICPC, NEERC, Northern Subregional Contest Problem I. Integral Polygons

题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229510
时间限制:2s
空间限制:256MB
题目大意:
给定一个凸多边形,有一种连接两个顶点可以将多边形分成两个非空的面积为整数的图形,询问这种线有多少条。
数据范围:
4 ≤ n ≤ 200 000
−109 ≤ xi, yi ≤ 109
样例:
2016-2017 ACM-ICPC, NEERC, Northern Subregional Contest Problem I. Integral Polygons_第1张图片
2016-2017 ACM-ICPC, NEERC, Northern Subregional Contest Problem I. Integral Polygons_第2张图片
代码:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair pii;
typedef vector vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pi acos(-1.0)
#define mem0(a) memset(a,0,sizeof(a))
#define memf(b) memset(b,false,sizeof(b))
#define maxn 401010
int x[maxn],y[maxn];
int va[maxn],pre[maxn],p[maxn][3][3][3];
int across(int a,int b,int c,int d)
{
    return a*d-b*c;
}
int main()
{
    freopen("integral.in","r",stdin);
    freopen("integral.out","w",stdout);
    mem0(p);
    mem0(pre);
    int n;
    cin>>n;
    rep(i,1,n+1)
    {
        cin>>x[i]>>y[i];
        x[i]=x[i]&1;
        y[i]=y[i]&1;
        x[i+n]=x[i];
        y[i+n]=y[i];
    }
    rep(i,1,n<<1|1)
    {
        va[i]=across(x[i-1],y[i-1],x[i],y[i]);
        pre[i]=pre[i-1]+va[i];
    }
    if(pre[n+1]&1)
    {
        cout<<"0"<

你可能感兴趣的:(2016-2017 ACM-ICPC, NEERC, Northern Subregional Contest Problem I. Integral Polygons)