题意:

    给出平面上n个点,问能在其中选出6个点,组成两个三角形,使得其互不相交

    问有多少种选法

  大致思路

     考虑枚举一条直线,将所有得点分为左右两部分,其中有两个点在直线上,

    以这两个点为顶点,分别统计左边有多少个三角形,右边有多少个三角形即可。

    枚举直线时,枚举一个点,然后对其他点极角排序,
    枚举另一个点,可快速算出该直线左右两边的点的数量(二分,叉积),组合一下即可。

    

 /*
: .
:
i
i .
i
: .
i .
i .
i
: .
i . i i : . . . . . . . .. . . .
. . . . . . . . .
: qQ . v2d . i: ..:ij.iBE .i EBj .irrivri.::iiiir7r. . SPd. :
i UQB .BBBBE BBBQBBBBLiBB.1BBi :X: BBu . .KBBBBBBBBBBBBBBBQv :BBBBB
. iBY PD. BBY vBBv. ..:gB1 rBM 7B1 RQP MBgvPPQBB uRq. .. . jBBQ.BBBr
:.BBrQBBBBBL iQBB7:777gBSYvrKBBv:v71r..YPBBBBBBBBBBEBBB 7RBZQdBBBdEgBQE 1QBB1 QBBB:
.:BBBBJ.qBBDBBBBBBBvrQBQBBBBBBBBBBBBBgg5UBBBBriiBQ1 rBB .:.:i. :KQBi ..:: :.. . . . ..... UBBB5 UJ: rBBBBXi
. IQY i:.:.. YBs :BB IE. XBZ QBs 7BB rBBBBQBBBBBBBQBBBBq BQBBBBBBBBBBBBBBBBviBBE. .BBZ .BBgi.
. BBBQSJ.Kb5BQgRBPv :5gQBBBQBB:YBvrBBd QBE BBdiBBBB5 .BB uBs iririiiriir7iii77i. ii .BBD .
. uQ5Sv .BB::i::QBU BBQMBK. 7BBBP. DBq QB1 DQ7.L. sBBdQBBMBBBQBBBBBQDi BB5
. ...:BB KBJ uB1 UBBBL QBL RQb i:. BBPvi.UBBuY7v7iQBqrrur. BBE .
:LBBBBBBJQBBBBQBBBJ :rvBBu:BBB1jBBPbBB SBBZIvSUguJXRBBB: 7QBB BBu .. BBQ
r.XX... .QBIYXDJBB1 qBBBBi ir rMQBQ. .sPBBBBBBBBRBBD7 XBBi dB1. . .. .BBg
i . . . . . .. ... .
:
i . .
i
i .
i :r:.
i . . vKKSj. .
r .. :B: js .
i . . rK .S: :::
r :v LS . ibi7gv .
i :Ligi .QJ :g7 .
. ...5d: . i2Sd rb. vj: .
. .7:r27DBi . .Bb: . 7K..Ps
uij1Pdr. ri . Sq :Kj7Ii . . :v:
UvY: 7P. . . .7 .vIqX. .. . .dBRS7.
. . qP . . . .. . . .. :r. .qi :2ZPi
. . gs . .:K2 . .irvIs75K5XEKMKgZsD522YLri. iBB1i Pr .2r
i iS: .isjjQ. .:rs5KPPMBBBZdBBgi:7Rd7XBBBRSMBBDZQZSr. rDYiiYdQSr. dY
: Ys .iXbi. 7: 7v5gQZqPEKXUIjUIdbr ur jRQr1E: .rJgBBDL: iEv .sdD5Yi. MX . .
i Si .vU57i .ibQBBgMPI175XUvsq5LBj :Li. jQLJ: . .rdBBQsYL :r1ISv: .gu .
: .. iU r5Qu. :sBBD7qDqbbijPj5ISXv22UK .BY . .gSP: .q: rBBBBS . . .7KEYi. qv .
. qBsY1i :IqBZqI2rUXLXQPrYjIuED2jZPv. KI . . .BR. rd .bBUBQu. . .isZK1: 5s
: vPv. .idDBEP1XYKXQR1r5d2SdPqEDv7IEY Yv . KB.:U. :Ui .BJUBBB1 . rXqIrrB2 .
v rQDM1dj7SM1qIuPgXJKS2sKU5urLDMr :Bi . .dBMi7BPYJ 1PKL: BjKIUPBB1 . . :irMX
i . .vKDDr1YREIPgv1qS1Qbju1IS2US5vUZBu sr . :BBBBdXMDMgjv. : guJsP7rQgU: JdrsSv:
7 rQREJ5u2vuKv5dXKKPXqqXK1PSSqP2USqqBDj . 7QBQRPQriQg:..v7i:. MqEXBs72DQB: .iYYr..iPRJ
7 . .MRB221QqKrYSSXdXXuBZuSguL1sPMDQQDPPgBi . :RBBMB5 PELBBBj vP. irRBgRPEv .Ju7ivv7vLi. .
: 7DQUdSPqgIqUsKSYv5Si2PrruJSBZR5r:: :Z: .irvX::qPPZMBBQgs .Xs LPuXBBi :Dd2rLsr. .
i YBZ7Lg2bUPLb172Xr7PQvJuuuMBbX7. .uRu. :QEBQRRBZgggQBSrY. :SQQX :27:. .
i .EP2PX1qJYIPuu5I2g2uB5YXbDZPJ .rr. . 7gZU7r7vYvvvJqBQRBMdgDMgBQQr r5BBr
.gB2LgEsPPuKE2IrM5Iu1U2JXgS. :7vvvsYLL7. .rs77JJr. JBQDBbdEZBRgBP . .YIUvirvBQ: .
XQQSqgDJ7qg5bPXqLd1bQ2JQB2. ..:7Lv7: iBQSREEBQQRBP: iSPL7. rBu
QgUjEE2qJbKsjX2duqYKr5BS. .. .rYr. dBQBZBQBKgM. . rZ2: jEi
vJdPIJI5UPSYKb5uLbLSDEu . :BBgBPEBr . .... . iBK.
YvLb7K5L7ubsjgJuuSsPQ7 .....:iiirr77v7vrv1PXU77rr::. :E. . .. .. sgi
LuKQrsSd5XQPqSij7bBu :ivu5J7i::::::::::i::.::iri.. :Ei. ..i715qLPdUqS. iBi .
7UPBv2IPqP1IdXLZZPr . . .sY .ir:. .. .QE ..
UsJRubSv7ggUJr1Qg: .. r5 vd.
d5YPrSqX7QIvPRBX. . . ..:i777r7vJvr: . .rZ . .iE5rr
2LKXj2E17DjSMSQi ..ii7uqS522J7:..... .. 7Z. . .75Y::. 7KdBZEXXBQ:
r7PQqdEjJEPJuZJ iIPK1j7:.:. .:i:...... :P .iLuvPSsXQbr .JBP
sLPP1uqs2XR7JQ: .:i. .:71ZBBBQEDDMbdMBBBdui: rZ. . bB.
UUqK7vSIv5PuDg .YdQBBBBQBMESJ777s1bPdEgRQBBRUi. .5 . .gq
vLZPvvbKLdSIBv . 1MBRQBBBMEbZPvgBRJrLY7Uj2J7rvPDQBBgUY722 ... .. iBJ
irIKvUPI7M1SRi . . 7BB1JUvSd1Y512IYSBMKLPv1XirsivvUKgDgBBBBBBKr:. .. uE.
D2KIJ5D17EPdd. . qBJv.ivivYi7JvrLrLEgbbP1PE:71sS5sDq7vDQD2qbgBBBMJi rR7
vJPbvJq2YgEQ2 .BP.L7ijIEuiivr7vii1PKgg5dRjXgUSujJ7JgJ7Piru1UKMBBQM2i .2I:.
vrXP1Xg2vJjbL . . sBBuXI1gBgE2SI7vIrrsIiSISdBSEZ1bggQv7Es:U77YLirugggDBBBgKUJrri:.:7IEP.
XU1UubPuLu7LY . :5RBgUBBPPdggBEUdqIKXviuJrYdPPq2PKKBqY1jrj75I1LL7UXZBBdPEQBP7jIIdKSBB. .
sIDbX5X5KRBSE .ZXLXI7q57UJ5IRUUZP5KZguivSv1S55bS12BMBjJ7dXBgZIqr7dqMEPBEQQ: KB7 ... ..
PU7v5MPJ7KZPD iBbU7v77:r7irYdIud5KqZPsrs2vYUsJuPP5SLKgQdEEgdPgMX7qvI5DXbMX :BQ
511sSdZXI51vg. . LgXgU77iir5dddBMMBBBP5dP52S2gBQ2vL22RdBQBPQP15SdMR1Jivrr:MBr SBv .jDBMbuv: ..
vU52sujjUEq1E. . . 2MrBDU5PQBZP7.:..irDQQPdBBRqi. .:jXQMBPrIjXXBP1iuii.BE .BX rSQK:...i1dX7.
KJ1svuqsrEgPK . v1rDQDBj:. .LQBS. .JBE.r7555RbbK55PBr . Kg 7QM. 7BBv
PXdEu5PsLKv5di 7E1dKi :J. :gg1iq1LsQRRYuBP .r KQi iBg .2Q5. .
IjPP1ID5UJYdBY rBBS . . :BErj7YU5ZPdBZ vBv :Rd IBi
2UKK7JPXuIgQBb . bBi . . . . EBPYv7srIKBB vBr sBi . .B1
vvbb15d5bSPLPB: . rB: .. . :qBKQvYLJRK iQ2 :ZBBr . Rv .
SY57vDIKZLuuKBi .BB. . . . bBXgudD5v .2BBgqqbgBJ . ... .E5
v75vYqPPq5KPjJE: . iBBr . .BMvBQEv: BBq1EsSQS5Bi . . :BL
vUUs7YuJrXJd7:BP . .PQqv: .. .:77juBQJsi rBQYiJU1JX5PRb: vBL .
dZsY55RS1qjdqrBBL .JPMRP77. .:.....:.:i7vjuSqEEbXqqquL7. . .jBQJvdR5vuuuJ5BBq: isBB . .
BQ7v1KDu5qYSqsJgQ: .r7IEPUs11uj25X21JJri::... 7QB1rPQY2duIQKXZJ7BBdu7:isDZ5: ..
LYRgsvSUPqX1UUI2Bd. ii2MEgI7dRSJ1sSBX7SPXsPZBBXr77.
vBB1PBZMQggZDZMXgBBDgMRbbEQQRZPZRPKSPbDRBDKujsuYv25Ys2qSEPDMMddZgZMQBBBgQBQEPsqXJSqsIP52M5UPPsvERZi
s5QgPQBIDMMDgDgDgBBgEBBBBBBQQBBBBQBBBBBQQBBBBBBBBQBBBBBQBBBBBBBBBQBBBBBBBMBQgESDDSEKUPgU2qSqUrPBBv. .
rrPBBgMDMQRRMQgQDMQBQBMgRQggDgRBBBgZgBBBQBBBBBBBBBBBBBS: ..vbBBBQBQMbSQQMEYSuLI5uPKv1D77PBBXi ...
i LdMdKKqqPgZSgd1PZPSLXPXSZZXPZIQZJ5EKdDgMMdqYr.::.:bB: LBXIQBKPgBquP2PZuUuUSXj5ZqXBB7
i:BP2j:vYs7q5sZI:2uvv7Ss7UYKs51r51rJLjDg7: .BvPPgX1vrii:2Qi vBbIMQuZrsDP55uu2XYdBQU: .
rPBLJ27PXu7SP2QIvSJsPKgYPPisXq1Lg51ZBdr 2Q: .. .qBU.:vbv. :IQBqiSs2KYLudKv7QQb.
BBXr7P1PXXsPSjD5757YPPE1JJiXPZj7sSQK: 1v iBu g7 . iDBPQsIPuIP7vZB1. .
MuiK7uKKj11Pj:S1UbuJXv2JJSKKLU2rSgX .....:::...::.: .Bd..i.:bj .SB7 .:: KBgMv1gu2KqDBZ: .:ii:ri::iiirrrviii7i.
*/ #include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<time.h>
#include<cstdlib>
#include<cmath>
#include<list>
using namespace std;
#define MAXN 10000006
#define eps 0
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fore(i,a,b) for(int i=a;i>=b;i--)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define cr clear()
#define sz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false)
#define fr freopen
#define pi acos(-1.0)
#define Vector Point
#define fir first
#define sec second
#define it_s_too_hard main
const long long inf=1LL<<;
const int iinf=<<;
const double dinf=1e17;
const int Mod=1e9+;
typedef long long ll;
typedef long double ld;
struct Point{
ll x,y;
double ang;
Point(ll x=,ll y=):x(x),y(y) {}
Point operator - (const Point &a)const { return Point(x-a.x,y-a.y);}
};
ll Cross(Vector a,Vector b){ return a.x*b.y-a.y*b.x;}
int n;
Point o;
Vector v1,v2;
bool cmp(Point a,Point b){
return a.ang<b.ang;
}
Point p[],tp[];
void I_can_t_solve_it(){
cin>>n;
ll ans=,cnt1,l,r,ct;
For(i,,n) cin>>p[i].x>>p[i].y;
For(i,,n){
For(j,,n) {
if(j==i) continue;
if(j>i) tp[j-]=p[j]-p[i],tp[j-].ang=atan2(tp[j-].y,tp[j-].x);
else tp[j]=p[j]-p[i],tp[j].ang=atan2(tp[j].y,tp[j].x);
}
ct=n-;cnt1=;
sort(tp+,tp+ct+,cmp);
For(j,,ct) tp[j+ct]=tp[j];
For(j,,ct){
if(j>cnt1) cnt1=j;
if(cnt1>ct*) break;
while(cnt1-j+<=ct && cnt1<ct* && Cross(tp[j],tp[cnt1+])>) cnt1++;
l=cnt1-j;r=n--l-;
ans+=l*(l-)*r*(r-)/;
}
}
cout<<ans/<<endl; }
int it_s_too_hard(){
int t=;
iossy;
For(i,,t){
I_can_t_solve_it();
}
return ;
}

[CodeForces]CodeForces - 1025F Disjoint Triangles的更多相关文章

  1. CodeForces - 1025F:Disjoint Triangles (几何)

    A point belongs to a triangle if it lies inside the triangle or on one of its sides. Two triangles a ...

  2. Codeforces Codeforces Round #484 (Div. 2) D. Shark

    Codeforces Codeforces Round #484 (Div. 2) D. Shark 题目连接: http://codeforces.com/contest/982/problem/D ...

  3. Codeforces Codeforces Round #484 (Div. 2) E. Billiard

    Codeforces Codeforces Round #484 (Div. 2) E. Billiard 题目连接: http://codeforces.com/contest/982/proble ...

  4. Codeforces 1119E Pavel and Triangles (贪心)

    Codeforces Global Round 2 题目链接: E. Pavel and Triangles Pavel has several sticks with lengths equal t ...

  5. 【codeforces 553C】Love Triangles

    [题目链接]:http://codeforces.com/problemset/problem/553/C [题意] 给你n个点,m条边; 每种边有2两种类型; 让你补充剩下的边,构造一个完全图; 使 ...

  6. CodeForces 682E Alyona and Triangles (计算几何)

    Alyona and Triangles 题目连接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/J Description You ar ...

  7. Codeforces 1355 C. Count Triangles

    传送门:C - Count Triangles  题意:给你四个数A,B,C,D,求有多少个三边为x,y,z (A ≤ x ≤ B ≤ y ≤ C ≤ z ≤ D)的三角形. 题解:枚举 x=A~B, ...

  8. Codeforces Codeforces Round #316 (Div. 2) C. Replacement set

    C. Replacement Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/570/proble ...

  9. Codeforces Codeforces Round #316 (Div. 2) C. Replacement 线段树

    C. ReplacementTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/570/problem ...

随机推荐

  1. c# 判断一个数是不是质数或者求一个数的公约数的算法

    一个数是不是质数,就是判断一个数除了1和它本身还有没有其他的约数,如果有则是合数,否则是质数.其实本质都是求公约数. 求公约数是什么思路呢,就是找比它小的数不断尝试,能被整除则是其约数,否则继续尝试, ...

  2. 腾讯高级设计师谈微信的旧容与新妆,Android Design是大势所趋

    编者按:本篇投稿选自腾讯大讲堂(更多腾讯产品技术文章,可以关注“腾讯大讲堂”微信公众账号),由腾讯研发管理部高级设计师Vertu撰写,他以产品设计师的视角,对比解读了微信的旧容与新妆,也讲了Andro ...

  3. CSS命名方法(笔记)

    划分CSS的一些方法(不同的划分方法都有利与弊,要记住,最合适项目的才是最好的): ①按功能划分:将字体的CSS存放在font.css.将控制颜色的CSS存放在color.css.将控制布局的CSS存 ...

  4. soj1010. Zipper

    1010. Zipper Constraints Time Limit: 1 secs, Memory Limit: 32 MB Description Given three strings, yo ...

  5. 微服务深入浅出(9)-- Nginx

    Nginx ("engine x") 是一个高性能的HTTP和反向代理服务器,处理请求是异步非阻塞的,多个连接(万级别)可以对应一个进程.而Apache是同步多进程模型,一个连接对 ...

  6. jquery对不同id的按钮执行同一类型的操作

    不同id执行相同操作: $("#id1,#id2,#id3,#id4") 获取相同class的text值: $(".className").each(funct ...

  7. 苹果手机浏览器$(document).on(“click”,function(){})点击无效的问题

    <label class="js_highlight" style="display: inline-block;float: left;width: 50%;&q ...

  8. GridView Postback后出错Operation is not valid due to the current state of the object.

    一.问题起因 最近项目中有一页面第一次search后正常,但是再次点击其它任何按钮都会报错,亦即postback后页面有问题,经检查是由于页面有一GridView且数据量极大,记录大概有上千条,这儿解 ...

  9. python基础--面向对象

    什么是面向对象编程 OOP编程是利用“类”和对象来创建各种模型来实现对真实世界的描述. OOP具有可维护性和可扩展性 二:面向对象有那些特性 1)CLASS类:一个类是对拥有相同属性的对象的抽象.类拥 ...

  10. python去除html空格

    如下面的 <td> 柳暗花溟</td> html里面的空格&nbsp,想直接用strip()函数去除是不可能的,必须显式的去掉\xa0 例如以上的就可以这样的方式去除空 ...