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
样例:


代码:
#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;
}
2016-2017 ACM-ICPC, NEERC, Northern Subregional Contest Problem I. Integral Polygons的更多相关文章
- ACM ICPC 2016–2017, NEERC, Northern Subregional Contest Problem J. Java2016
题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229510 时间限制:2s 空间限制:256MB 题目大意: 给定一个数字c 用 " ...
- 2016-2017 ACM-ICPC, NEERC, Northern Subregional Contest Problem F. Format
题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229510 时间限制:1s 空间限制:512MB 题目大意: 给定一个字符串,使用%[...] ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest
目录 2018-2019 ICPC, NEERC, Southern Subregional Contest (Codeforces 1070) A.Find a Number(BFS) C.Clou ...
- Codeforces 2018-2019 ICPC, NEERC, Southern Subregional Contest
2018-2019 ICPC, NEERC, Southern Subregional Contest 闲谈: 被操哥和男神带飞的一场ACM,第一把做了这么多题,荣幸成为7题队,虽然比赛的时候频频出锅 ...
- 【2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest D】---暑假三校训练
2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest D Problem D. Distribution in Metagonia Input ...
- 模拟赛小结:2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest
2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest 2019年10月11日 15:35-20:35(Solved 8,Penalty 675 ...
- 2015-2016 ACM-ICPC, NEERC, Northern Subregional Contest (9/12)
$$2015-2016\ ACM-ICPC,\ NEERC,\ Northern\ Subregional\ Contest$$ \(A.Alex\ Origami\ Squares\) 签到 //# ...
- 2016 NEERC, Northern Subregional Contest G.Gangsters in Central City(LCA)
G.Gangsters in Central City 题意:一棵树,节点1为根,是水源.水顺着边流至叶子.该树的每个叶子上有房子.有q个询问,一种为房子u被强盗入侵,另一种为强盗撤离房子u.对于每个 ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror) Solution
从这里开始 题目列表 瞎扯 Problem A Find a Number Problem B Berkomnadzor Problem C Cloud Computing Problem D Gar ...
随机推荐
- PHpStorm + phpstudy 断点调试配置
步骤: phpstudy 其他菜单 ->打开配置文件 ->打开 php.ini ->找到 XDebug ->XDebug修改成下面文字 [XDebug] :红色 (1 ...
- 【JVM】TroubleShooting之内存溢出异常(OOM)与调优
1. OOM概述 If your application's execution time becomes longer and longer, or if the operating system ...
- 通过SSH服务登陆linux服务器(版本RHEL7)
通过SSH服务登陆linux服务器(版本RHEL7) SSH服务概述:是一种能够以安全的方式提供远程登陆的协议,也是目前远程管理linux系统的首选方式.在此之前,我们一般使用FTP或者telnet来 ...
- Python之路(五)-->> 格式化
在Python中格式化的方式有两种,一种是%,另外一种是format()格式化. ----------------------------------------------------------- ...
- WPF 带水印的密码输入框
原文:WPF 带水印的密码输入框 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/BYH371256/article/details/83652540 ...
- C#:设置CefSharp的一些参数,比如忽略安全证书
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 本次记录如何设置CefSharp忽略安全证书,以及他的一些其他配置 参考网址: https://peter.s ...
- JUnit在intellij idea中只能在test里面才能使用,否则不能添加import
只能在 src下的test下使用 不能再main下使用 否则不能import到指定的junit包 idea这样做的好处就是分离主项目和测试项目,这样一来就能够更加方便的测试了 如图直接这样把整个主包 ...
- javaweb(二十一)——JavaWeb的两种开发模式
一.JSP+JavaBean开发模式 1.1.jsp+javabean开发模式架构 jsp+javabean开发模式的架构图如下图(图1-1)所示
- Supervisor4.0和python2.7的crit问题,导致python进程阻塞
1.问题原因 Supervisor高版本在守护python2.7的服务时,会crit并报错并倒至进程阻塞(python进程存在,但不在运行)的问题,一般会和字符集有关系 <type 'excep ...
- textbox的验证
代码如下: textBox1.KeyDown += (a, b) => { if (b.KeyCode == Keys.Enter) { textBox2.Focus(); } }; textB ...