Submission #537764

#TimeUsernameProblemLanguageResultExecution timeMemory
537764inksamuraiKućice (COCI21_kucice)C++17
110 / 110
359 ms468 KiB
#include <bits/stdc++.h>
#define int ll
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rng(i,x,n) for(int i=x;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define vec(...) vector<__VA_ARGS__>
#define _3HspL4A ios::sync_with_stdio(0),cin.tie(0)
typedef long long ll;
using pii=pair<int,int>;
using vi=vec(int);
void print(){cout<<"\n";}
template<class T,class...E>
void print(const T&v,const E&...u){cout<<v<<' ',print(u...);}
// e 
 
//snuke's mod int
template <ll mod>
struct modint{
	ll x; // typedef long long ll;
	modint(ll x=0):x((x%mod+mod)%mod){}
	modint operator-()const{return modint(-x);}
	modint& operator+=(const modint a){if((x+=a.x)>=mod) x-=mod; return *this;}
	modint& operator-=(const modint a){if((x+=mod-a.x)>=mod) x-=mod; return *this;}
	modint& operator*=(const modint a){(x*=a.x)%=mod; return *this;}
	modint operator+(const modint a)const{modint res(*this); return res+=a;}
	modint operator-(const modint a)const{modint res(*this); return res-=a;}
	modint operator*(const modint a)const{modint res(*this); return res*=a;}
	modint pow(ll n)const{
		modint res=1,x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}
	modint inv()const{return pow(mod-2);}
};
using mint=modint<1000'000'007>;
 
using ld=long double;
 
struct P{
	ld x,y;
	P(ld _x=0,ld _y=0):x(_x),y(_y){}
	P operator+(const P &p){ return {x+p.x,y+p.y}; }
	P operator-(const P &p){ return {x-p.x,y-p.y}; }
	P operator*(ld d){ return {x*d,y*d}; }
	P operator/(ld d){ return {x/d,y/d}; } // d!=0
	bool operator==(const P &p)const{ return x==p.x and y==p.y; }	
	bool operator<(const P &p)const{ return x!=p.x?x<p.x:y<p.y; }	
 
	ld norm(){ return x*x+y*y; }
	ld abs(){ return sqrt(norm()); }
};
ld dist(P a,P b){
	return (a-b).abs();
}
ld ccw(P a,P b,P c){
	return a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y);
}
 
int sgn(int x){
	return (x<0?-1:1);
}
 
bool cmpup(P a,P b){
	if(sgn(a.x)!=sgn(b.x)){
		return sgn(a.x)<sgn(b.x);
	}
	return (a.y*b.x>b.y*a.x);
}

bool cmplo(P a,P b){
	if(sgn(a.x)!=sgn(b.x)){
		return sgn(a.x)<sgn(b.x);
	}
	return (a.y*b.x<b.y*a.x);	
}

signed main(){
_3HspL4A;
	int n;
	cin>>n;
	vec(P) a;
	rep(i,n){
		int x,y; cin>>x>>y;
		a.pb(P(x,y));
	}
	mint ans=0;
 
	auto quq=[&](int pivot){
		vec(P) hi,lo;
		rep(i,n){
			if(i==pivot) continue;
			P pnt=a[i]-a[pivot];
			if(pnt.y>=0) hi.pb(pnt);
			else lo.pb(pnt);
		}
		sort(hi.begin(),hi.end(),cmpup);
		sort(lo.begin(),lo.end(),cmplo);
		P pnt(0,0);
		int nhi=sz(hi),nlo=sz(lo);
		{
			int j=nlo;
			rep(i,nhi){
				int now=nhi-i-1;
				while(j>0 and ccw(hi[i],pnt,lo[j-1])>=0){
					j-=1;
				}
				now+=nlo-j;
				ans-=mint(2).pow(now);
			}
		}
		{
			int j=-1;
			per(i,nlo){
				int now=i;
				while(j+1<nhi and ccw(lo[i],hi[j+1],pnt)<0){
					j+=1;
				}
				now+=j+1;
				ans-=mint(2).pow(now);
			}
		}
	};
	
	rep(i,n){
		quq(i);
	}
	ans+=mint(2).pow(n)*n;
	ans-=n;
	print(ans.x);
//
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...