Time card is tight, g++ 3400ms over, C + + timed out.
Double keyword sort, and then from the left one point to see the past, assuming that I point is required, and then the point after I as the point for the origin of the polar sort, the polar angle of the same row (can be sorted in addition to GCD), and then statistics can be. Focus needs attention.
#include <cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<vector>#include<map>#include<Set>#include<queue>#include<stack>#include<iostream>using namespaceStd;typedefLong LongLL;voidFile () {freopen ("D:\\in.txt","R", stdin); Freopen ("D:\\out.txt","W", stdout);}Const intmaxn= ++Ten;ConstLL mod=1e9+7; LL H[MAXN];structX {LL x, Y,} P[MAXN],T[MAXN];intT,N,NUM[MAXN];BOOLCMP (X a,x b) {if(a.x==b.x)returna.y<b.y; returna.x<b.x;} ll GCD (ll A,ll b) {if(b==0)returnAreturnGCD (b,a%b); }intMain () {h[0]=1; for(intI=1; i<= +; i++) h[i]= (2*h[i-1])%MoD; scanf ("%d",&T); while(t--) {scanf ("%d",&N); for(intI=0; i<n;i++) scanf ("%lld%lld",&p[i].x,&p[i].y); Sort (p,p+N,CMP); P[n].x=p[n].y= (LL)0x7fffffff; for(intI=0;i<N;) { intf=i; for(;; f++)if(p[i].x!=p[f].x| | P[I].Y!=P[F].Y) Break; for(intj=i;j<f;j++) num[j]=f-i-(j-i); I=F; } LL ans=0; for(intI=0; i<n;i++) {ans= (ans+h[num[i]-1]-1)%MoD; intsz=0; for(intj=i+num[i];j<n;j++) {t[sz].x=p[j].x-p[i].x,t[sz].y=p[j].y-p[i].y; LL GCD=gcd (ABS (t[sz].x), ABS (T[SZ].Y)); t[sz].x=T[SZ].X/GCD, T[SZ].Y=T[SZ].Y/GCD; sz++; } sort (T,t+SZ,CMP); T[sz].x=t[sz].y= (LL)0x7FFFFFFF; intCnt=1; for(intj=0; j<sz;j++) { if(t[j].x==t[j+1].x&&t[j].y==t[j+1].Y) cnt++; ElseAns= (ans+h[num[i]-1]* (h[cnt]-1)%mod)%mod,cnt=1; }} printf ("%lld\n", ans); } return 0;}
HDU 5738 Eureka