首页 技术 正文
技术 2022年11月14日
0 收藏 678 点赞 4,380 浏览 1816 个字

题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229510

时间限制:2s

空间限制:256MB

题目大意:

给定一个凸多边形,有一种连接两个顶点可以将多边形分成两个非空的面积为整数的图形,询问这种线有多少条。

数据范围:

4 ≤ n ≤ 200 000

−109 ≤ xi, yi ≤ 109

样例:

代码:

#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> 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"<<endl;
return 0;
}
//rep(i,1,n<<1|1)
//{
//printf("%5d",x[i]);
//}
//cout<<endl;
//rep(i,1,n<<1|1)
//{
//printf("%5d",y[i]);
//}
//cout<<endl;
//rep(i,1,n<<1|1)
//{
//printf("%5d",pre[i]);
//}
//cout<<endl;
rep(i,1,n<<1|1)rep(a,0,2)rep(b,0,2)rep(c,0,2)
{
if(x[i]==a&&y[i]==b&&(pre[i]&1)==c)
p[i][a][b][c]=p[i-1][a][b][c]+1;
else
p[i][a][b][c]=p[i-1][a][b][c];
}
//cout<<endl;
//rep(i,1,n+1)
//{
//rep(a,0,2)
//rep(b,0,2)
//rep(c,0,2)
//{
//printf("%5d",p[i][a][b][c]);
//}
//cout<<endl;
//}
//cout<<endl;
ll ans=0;
rep(i,1,n+1)
{
int l=i+2,r=n+i-2;
rep(a,0,2)rep(b,0,2)rep(c,0,2)
{
int t=((x[i]*b-y[i]*a+c-pre[i])&1);
if(t==0)ans+=p[r][a][b][c]-p[l-1][a][b][c];
//printf("%5d",ans);
}
//cout<<endl;
}cout<<ans/2<<endl;
return 0;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,492
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,495
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,132
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,295