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 ...
随机推荐
- Loadrunder之脚本篇——参数化在场景中的运用
Action() { lr_eval_string("{NewParam}"); lr_eval_string("{NewParam}"); return 0; ...
- jsp导出
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- Linux用户和用户组管理 用户管理相关命令
用户添加命令 useradd 注意: 新添加的用户如果不设定密码是不能够登录系统的 命令格式: [root@localhost ~]#useradd [选项] 用户名 选项说明: 选项 选项说明 -u ...
- Android摄像头测量尺(Advanced Ruler Pro)使用方法
http://www.cnblogs.com/sinojelly/archive/2010/08/13/1799341.html Advanced Ruler Pro是一个Android手机应用程序, ...
- Python编程-架构、Socket
一.客户端/服务器架构 1.C/S架构 Client/Server架构,即服务器/客户端架构. 客户端和服务器端的程序不同,用户的程序主要在客户端,服务器端主要提供数据管理.数据共享.数据及系统维护和 ...
- Model FEP 快易播看板推播系统
主要特色: 低成本,快速导入 透过Wi-Fi 方式推播,现场架设容易 采Web Browser 介面登入操作,简单快速 模组化版面设定,弹性调整资料呈现方式 可整合多种连线方式与外部资料库沟通 可自行 ...
- IMP导入小记
1.创建表空间 create tablespace example_tablespace datafile 'e:\****.dbf' size 10m reuse autoextend on nex ...
- JAVA基础补漏---数组
int[] a = new int[5]; int[] b = new int{1,2,3}; int[] c = {4,5,6}; 以上几种定义都可以. a叫动态初始化. b叫静态初始化. c叫静态 ...
- oracle 启动数据库与监听器
1.oracle 启动数据库与监听器 1)启动数据库 oracle用户进去 oracle/oracle sqlplus / as sysdba 然后startup 退出,然后启动监听进程 2)启动监听 ...
- YARN中的失败分析
YARN中的失败分析 对于在YARN中运行的MapReduce程序,需要考虑以下几种实体的失败任务.application master.节点管理器.资源管理器 1. 任务运行失败 任务运行失败类似于 ...