bzoj 4814: [Cqoi2017]小Q的草稿【计算几何】
//先打个50暴力,10min50分简直美滋滋~
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=5005;
const double eps=1e-8;
int n,t,m,ans;
struct dian
{
double x,y;
dian(double X=0,double Y=0)
{
x=X,y=Y;
}
dian operator + (const dian &a) const
{
return dian(x+a.x,y+a.y);
}
dian operator - (const dian &a) const
{
return dian(x-a.x,y-a.y);
}
}a,b,c,p[N];
struct bian
{
dian s,t;
bian(dian S=dian(),dian T=dian())
{
s=S,t=T;
}
}l[N];
int read()
{
int r=0,f=1;
char p=getchar();
while(p>'9'||p<'0')
{
if(p=='-')
f=-1;
p=getchar();
}
while(p>='0'&&p<='9')
{
r=r*10+p-48;
p=getchar();
}
return r*f;
}
int sgn(double x)
{
return x<-eps?-1:x>eps;
}
double cj(dian a,dian b)
{
return a.x*b.y-a.y*b.x;
}
bool lc(dian a,dian b,dian c,dian d)
{
return sgn(cj(c-a,b-a)*cj(b-a,d-a))>=0;
}
bool jiao(dian a,dian b,dian c,dian d)
{
return lc(a,b,c,d)&&lc(c,d,a,b);
}
bool ok(dian a,dian b)
{
for(int i=1;i<=m;i++)
if(jiao(a,b,l[i].s,l[i].t))
return 0;
return 1;
}
int main()
{
n=read(),t=read();
for(int i=1;i<=n;i++)
p[i].x=read(),p[i].y=read();
for(int i=1;i<=t;i++)
{
a.x=read(),a.y=read(),b.x=read(),b.y=read(),c.x=read(),c.y=read();
l[++m]=bian(a,b),l[++m]=bian(b,c),l[++m]=bian(c,a);
}
for(int i=1;i<=n;i++)
for(int j=i+1;j<=n;j++)
if(ok(p[i],p[j]))
ans++;
printf("%d\n",ans);
return 0;
}
bzoj 4814: [Cqoi2017]小Q的草稿【计算几何】的更多相关文章
- BZOJ 4814 Luogu P3699 [CQOI2017]小Q的草稿 (计算几何、扫描线、set)
题目链接 (BZOJ) http://lydsy.com/JudgeOnline/problem.php?id=4814 (Luogu) https://www.luogu.org/problem/P ...
- bzoj 4813: [Cqoi2017]小Q的棋盘 [树形背包dp]
4813: [Cqoi2017]小Q的棋盘 题意: 某poj弱化版?树形背包 据说还可以贪心... #include <iostream> #include <cstdio> ...
- bzoj 4815: [Cqoi2017]小Q的表格 [数论]
4815: [Cqoi2017]小Q的表格 题意: 单点修改,查询前缀正方形和.修改后要求满足条件f(a,b)=f(b,a), b×f(a,a+b)=(a+b)*f(a,b) 一开始sb了认为一次只会 ...
- bzoj4814: [Cqoi2017]小Q的草稿
Description 小Q是个程序员.众所周知,程序员在写程序的时候经常需要草稿纸.小Q现在需要一张草稿纸用来画图,但是桌上 只有一张草稿纸,而且是一张被用过很多次的草稿纸.草稿纸可以看作一个二维平 ...
- bzoj 4813: [Cqoi2017]小Q的棋盘
Description 小Q正在设计一种棋类游戏.在小Q设计的游戏中,棋子可以放在棋盘上的格点中.某些格点之间有连线,棋子只能 在有连线的格点之间移动.整个棋盘上共有V个格点,编号为0,1,2-,V- ...
- bzoj 4815: [Cqoi2017]小Q的表格【欧拉函数+分块】
参考:http://blog.csdn.net/qq_33229466/article/details/70174227 看这个等式的形式就像高精gcd嘛-所以随便算一下就发现每次修改(a,b)影响到 ...
- BZOJ 4815 CQOI2017 小Q的表格 欧拉函数+分块
题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=4815 题意概述:要认真概述的话这个题就出来了... 分析: 首先分析题目,认真研究一下修 ...
- bzoj 4815 [Cqoi2017]小Q的表格——反演+分块
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4815 大概就是推式子的时候注意有两个边界都是 n ,考虑变成 2*... 之类的. 分块维护 ...
- BZOJ 4815 [Cqoi2017]小Q的表格 ——欧拉函数
把式子化简一波. 发现一个比较厉害的性质:每个点只能影响到行列下标$gcd$与它相同的点. 然后就可以计算$\sum_{g<=k}f(g,g)*\sum_{i<=k}\sum_{j< ...
随机推荐
- 网络安全法与LogSec日志安全大数据审计平台
https://blog.csdn.net/chengpeng1144/article/details/73555331 https://blog.csdn.net/dcbeyond/article/ ...
- HDU1087 Super Jumping! Jumping! Jumping!(LIS)
题目意思: http://acm.hdu.edu.cn/showproblem.php? pid=1087 此题的意思求最长上升子序列的和. 题目分析: 在求最长上升子序列的时候,不在保存最长的个数, ...
- centos 5.11修改ssh默认端口号
查看下服务器端口号范围: # sysctl -a|grep ip_local_port_range net.ipv4.ip_local_port_range = 32768 61000 新 ...
- VC++如何折叠代码
工具-选项,然后在文本编辑器,C/C++中的格式设置,把大纲语句块设置为True 这样之后,还是不能像C#一样使用region折叠代码,但是可以方法和if语句都会自动显示可以折叠. 使用#pr ...
- ZXing-core生成二维码和解析
如今二维码这么流行的时刻.也必须知道二维码是怎么生成.如今我们就来看看,是怎么生成的. 事实上主要是利用goggle公布的jar来使用:本文转自点击打开链接 1.二维码的生成 将Zxing-core. ...
- win7下装ubuntu双系统后无法进入win7的解决方法
本来电脑的系统是win7,然后用u盘装了ubuntu之后可能会出现开机没有引导界面而直接进入ubuntu系统的情况. 原因:没有设置gurb引导 解决方法:需要更新gurb来使ubuntu识别出win ...
- JS地区四级级联
<script type="text/javascript" src="../js/jsAddress.js"></script> &l ...
- Ubuntu16.04下安装Tensorflow GPU版本(图文详解)
不多说,直接上干货! 推荐 全网最详细的基于Ubuntu14.04/16.04 + Anaconda2 / Anaconda3 + Python2.7/3.4/3.5/3.6安装Tensorflow详 ...
- Java使用三种不同循环结构对1+2+3+...+100 求和
▷//第一种求法,使用while结构 /** * @author 9527 * @since 19/6/20 */ public class Gaosi { public static void ma ...
- mysql 时间间隔计算
业务需求说明 早8:30点执行该sql,写入定时脚本 [在稳定前,需要手动复检] INSERT INTO test_error ( url, no_open_times, no_ad_times, o ...