bzoj 4814: [Cqoi2017]小Q的草稿【计算几何】
2024-09-03 21:02:10
//先打个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;
}
最新文章
- 在jQuery ajax中按钮button和submit的区别分析
- 可视化工具solo show-----Prefuse自带例子GraphView讲解
- Nao 类人机器人 相关资料
- Coursera台大机器学习技法课程笔记04-Soft-Margin Support Vector Machine
- Python 编码规范
- JDK5-静态导入
- iOS开发UI篇——简单的浏览器查看程序
- 基础算法-查找:线性索引查找(I)
- Spring MVC前后端的数据传输
- 浅谈编程语言中的新宠Python,你叫它如何不火?
- Manacher&#39;s Algorithm(马拉车算法)
- MySQL新参数log_error_verbosity
- linux之文件权限+用户权限
- JavaScript调用上下文(第九天)
- Celery 异步任务
- 数字图像处理的Matlab实现(2)—MATLAB基础
- eclipse tomcat报Several ports(8005 8080 8009)端口被占用问题解决方案
- leetcode python 010
- BZOJ.3510.首都(LCT 启发式合并 树的重心)
- 13: openpyxl 读写 xlsx文件
热门文章
- [Bzoj3611][Heoi2014]大工程(虚树)
- 登录页面练习servlet
- [Bash] View Files and Folders in Bash
- 火狐浏览器Firefox 如何下载网页的SWF视频,硅谷动力的网站视频怎么下载
- Win8系统如何在桌面行显示我的电脑
- INTERSECT(交集)集合运算
- jpa删除根据对象删除失败,报Removing a detached instance 错
- PHP 按位与或 (^ 、&;)
- POI 的使用
- ASP.NET没有魔法——ASP.NET MVC Razor与View渲染 ASP.NET没有魔法——ASP.NET MVC界面美化及使用Bundle完成静态资源管理