CodeForces - 13D :Triangles(向量法:问多少个蓝点三角形内部无红点)
Little Petya likes to draw. He drew N red and M blue points on the plane in such a way that no three points lie on the same line. Now he wonders what is the number of distinct triangles with vertices in red points which do not contain any blue point inside.
Input
The first line contains two non-negative integer numbers N and M (0 ≤ N ≤ 500, 0 ≤ M ≤ 500) — the number of red and blue points respectively. The following N lines contain two integer numbers each — coordinates of red points. The following M lines contain two integer numbers each — coordinates of blue points. All coordinates do not exceed 109 by absolute value.
Output
Output one integer — the number of distinct triangles with vertices in red points which do not contain any blue point inside.
Examples
4 1
0 0
10 0
10 10
5 4
2 1
2
5 5
5 10
6 1
8 6
-6 -7
7 -1
5 -1
10 -4
-10 -8
-10 5
-2 -8
7
向量法:这里写得很明了了:https://blog.csdn.net/v5zsq/article/details/79687164。。。(我还是太菜了
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int maxn=;
struct point{
int x,y; point(){}
}a[maxn],b[maxn];
ll det(point O,point A,point B){
return (1LL*A.x-O.x)*(B.y-O.y)-(1LL*B.x-O.x)*(A.y-O.y);
}
int dp[maxn][maxn];
int main()
{
int N,M,ans=; scanf("%d%d",&N,&M);
a[].x=-1e9-; a[].y=-1e9-;
rep(i,,N) scanf("%d%d",&a[i].x,&a[i].y);
rep(i,,M) scanf("%d%d",&b[i].x,&b[i].y);
rep(i,,N) rep(j,,N){
if(i==j||det(a[],a[i],a[j])<) continue;
rep(k,,M)
if(det(a[],a[j],b[k])<=&&det(a[j],a[i],b[k])<=&&det(a[i],a[],b[k])<=)
dp[i][j]++;
dp[j][i]=-dp[i][j];
}
rep(i,,N)
rep(j,i+,N)
rep(k,j+,N)
ans+=(dp[i][j]+dp[j][k]+dp[k][i]==);
printf("%d\n",ans);
return ;
}
CodeForces - 13D :Triangles(向量法:问多少个蓝点三角形内部无红点)的更多相关文章
- Codeforces 528E Triangles 3000 - 计算几何
题目传送门 传送点I 传送点II 传送点III 题目大意 给定$n$的平面上的直线,保证没有三条直线共点,两条直线平行.问随机选出3条直线交成的三角形面积的期望. 显然$S=\frac{1}{2}ah ...
- Codeforces 15E Triangles 【组合计数】
Codeforces 15E Triangles Last summer Peter was at his granny's in the country, when a wolf attacked ...
- [CodeForces]CodeForces 13D 几何 思维
大致题意: 给出N个红点和M个蓝点,问可以有多少个红点构成的三角形,其内部不含有蓝点 假设我们现在枚举了一条线段(p[i],p[j]),我们可以记录线段下方满足(min(p[i].x,p[j].x)& ...
- Codeforces 15E Triangles - 组合数学
Last summer Peter was at his granny's in the country, when a wolf attacked sheep in the nearby fores ...
- Codeforces 1060E(思维+贡献法)
https://codeforces.com/contest/1060/problem/E 题意 给一颗树,在原始的图中假如两个点连向同一个点,这两个点之间就可以连一条边,定义两点之间的长度为两点之间 ...
- Codeforces 10C Digital Root 法冠军
主题链接:点击打开链接 #include<stdio.h> #include<iostream> #include<string.h> #include<se ...
- HDU 1829 A Bug's Life 【带权并查集/补集法/向量法】
Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes ...
- Codeforces Round #313 C. Gerald's Hexagon(放三角形)
C. Gerald's Hexagon time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Gym 100015F Fighting for Triangles 状态压缩DP
F Fighting for Triangles Description Andy and Ralph are playing a two-player game on a triangular bo ...
随机推荐
- bootstrap-select 使用笔记 设置选中值及手动刷新
直接笔记: 1.页面刚加载完填充select选项数据时,需要手动刷新一下组件,否则没有选项值.(组件初始化时,li 与 option 分离的,需要刷新一下(据说)) $.post('/cpms/tod ...
- 转:Windows下USB接口驱动技术(二)
- ANSI编码——代码页
详见wiki: http://zh.wikipedia.org/wiki/%E4%BB%A3%E7%A0%81%E9%A1%B5
- xml转换为对象 微信接口
public sealed class XMLSerilizable { /// <summary> /// XML转换为对象 /// </summary> /// <t ...
- CSS伪元素实现的3D按钮
在线演示 本地下载
- HISAT2的运用
功能: 用于有参考基因组存在的比对工具(适用于whole-genome, transcriptome, and exome sequencing data) 用法: hisat2-build [opt ...
- 函数进阶之结合tornado
一.本篇博文内容 .协程函数 .面向过程编程 .递归和二分法 二.协程函数 协程函数:就是使用了yield表达式形式的生成器 首先函数的传参有几种? 三种: 1.实参形参传参 2.闭包的形式传参 3. ...
- 数据库系统概论学习3-SQL 语句和关系代数(一)SQL 入门
3. SQL 语句和关系代数(一)SQL 入门 3.1 数据库的编程语言 SQL 的优点 SQL 集成了数据查询(data query).数据操作(data manipulation).数据定义(da ...
- Android电容屏(二):驱动调试分析【转】
本文转载自:http://blog.csdn.net/xubin341719/article/details/7833383 以goodix的gt8105为例 一.总体架构 硬件部分:先看一个总体的图 ...
- 时间插件之My97DatePickerBeta
My97DatePickerBeta使用很简单 1.在jsp页面中 引入JS 下载地址:链接: https://pan.baidu.com/s/1bp5uzuv 密码: ya9a <script ...