codeforces 1284E
计数每一个点被被其他点组成的四边形完全包含的四边形的个数,给出的点没有三点共线的情况
官方题解如下,说的很清楚,也很有技巧
代码也是直接参考官方的题解来的
#include<bits/stdc++.h> #define forn(i, n) for (int i = 0; i < int(n); i++)
#define fore(i, s, t) for (int i = s; i < (int)t; i++)
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pf2(x,y) printf("%d %d\n",x,y)
#define pf(x) printf("%d\n",x)
#define each(x) for(auto it:x) cout<<it<<endl;
#define pi pair<int,int> using namespace std; char inline nc(){
static char buf[100000],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
} template <typename T>
bool rd(T& v){
static char ch;
while(ch!=EOF&&!isdigit(ch)) ch=nc();
if(ch==EOF) return false;
for(v=0;isdigit(ch);ch=nc())
v=v*10+ch-'0';
return true;
} template <typename T>
void o(T p){
static int stk[70],tp;
if(p==0) {
putchar('0');return ;
}
if(p<0) {
p=-p;putchar('-');
}
while(p) stk[++tp]=p%10,p/=10;
while(tp) putchar(stk[tp--]+'0');
} typedef long long ll; const int maxn=3e3+5;
const int maxm=4e5+5;
const int inf=1e9; int n; pi a[maxn]; ll C(ll n,ll m){
if(m>n) return 0;
if(n<0) return 0;
if(m>n-m) m=n-m;
ll ans=1;
for(int i=1;i<=m;i++)
ans*=n,ans/=i,n--;
return ans;
} ll cross(pi a,pi b){
return 1ll*a.fi*b.se-1ll*b.fi*a.se;
} int main(){
cin>>n;
for(int i=0;i<n;i++)
cin>>a[i].fi>>a[i].se;
ll tot=0;
for(int i=0;i<n;i++){
vector<pi> v;
for(int j=0;j<n;j++)
if(i!=j) v.push_back({a[j].fi-a[i].fi,a[j].se-a[i].se});
sort(all(v),[&](pi x,pi y){
bool b1=x<pi(0,0);
bool b2=y<pi(0,0);
if(b1!=b2) return b1<b2;
return cross(x,y)>0;
});
int j=0;
for(int i=0;i<v.size();i++){
while(j<i+v.size()&&cross(v[i],v[j%v.size()])>=0) j++;
tot+=C(j-i-1,3);
}
}
cout<<C(n,5)*5-tot<<endl;
}
codeforces 1284E的更多相关文章
- codeforces 1284E. New Year and Castle Construction(极角排序+扫描枚举)
链接:https://codeforces.com/problemset/problem/1284/E 题意:平面上有n个点,问你存在多少组四个点围成的四边形 严格包围某个点P的情况.不存在三点共线. ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
- CodeForces - 696B Puzzles
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
随机推荐
- 实例探究Aspectj,解析SentinelResourceAspect
为了学习SentinelResourceAspect,这篇文章里我用Aspectj实现一个AOP实例,一起来看下. Sentinel 提供了 @SentinelResource 注解用于定义资源,支持 ...
- python2 + Django 中文传到模板页面变Unicode乱码问题
1.确保views页面首行设置了默认编码 # -*-coding:utf-8 -*- 2.确保html页面的编码为 utf-8 3.确保项目setting文件设置了 LANGUAGE_CODE = ...
- vue路由--嵌套路由
静态嵌套路由: <!DOCTYPE html> <html lang="en"> <head> <meta charset="U ...
- Solr系列4-SolrJ开发应用
1: Solr导入 1.1导入POM # Base Code Java org.apache.solr solr-solrj 8.4.0 # spring boot org.springframewo ...
- 2020/1/4 H5&&C3笔记
1. 类名不能由数字开头 2.float 是float 属性定义元素在哪个方向浮动.有left / right / none / inherit四个 参考https://www.w3school.co ...
- 展讯sprd_battery.c 充电驱动
sprd_battery.c 是充电驱动,这个是充电功能的核心内容,电量显示策略.温度检测策略.充电保护机制等功能在这里实现,功能实现与硬件细节剥离,调用通用接口实现逻辑控制: 1 sprdbat_p ...
- 2020年如何成为一个高级AVA架构师(50W~100W年薪)
2020年如何成为一个高级AVA架构师(50W~100W年薪)
- VMware使用与安装
VMware安装 下载完Vmware -> 双击打开安装包 -> 选择下一步(如下图界面) 选择接受协议,点击下一步 选择经典进行安装.这个是默认安装,会把默认插件安装到相对应的路径 选择 ...
- 在window上安装mysql - MySQL5.7.24 版本
1.下载安装包 下载地址:https://dev.mysql.com/downloads/mysql/5.7.html#downloads 点击Download,选择 No thanks, just ...
- Github无法访问的解决办法
#github 192.30.253.113 github.com 192.30.253.113 github.com 192.30.253.118 gist.github.com 192.30.25 ...