Submission #531439

#TimeUsernameProblemLanguageResultExecution timeMemory
531439Rafi22Kućice (COCI21_kucice)C++14
110 / 110
113 ms452 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define st first #define nd second #define pb push_back #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #define ll long long ll mod=1000000007; int inf=1000000007; ll infl=1000000000000000007; int x[1007],y[1007]; ll p[1007]; ll cross(ll x1,ll y1,ll x2,ll y2){return x1*y2-y1*x2;} bool cmp(int l,int r) { bool a=x[l]>=0,b=x[r]>=0; if(a!=b) return a>b; return cross(x[l],y[l],x[r],y[r])<0; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; for(int i=1;i<=n;i++) cin>>x[i]>>y[i]; p[0]=1; for(int i=1;i<=n;i++) p[i]=p[i-1]*2%mod; ll ans=p[n]*(ll)n%mod; for(int i=1;i<=n;i++) { ans=(ans-1+mod)%mod; int dx=x[i],dy=y[i]; for(int j=1;j<=n;j++) x[j]-=dx; for(int j=1;j<=n;j++) y[j]-=dy; vector<int>V; for(int j=1;j<=n;j++) if(i!=j) V.pb(j); sort(all(V),cmp); int k=0; for(int j=0;j<n-1;j++) { k=max(k,j); while(cross(x[V[j]],y[V[j]],x[V[(k+1)%(n-1)]],y[V[(k+1)%(n-1)]])<0) k++; ans=(ans-p[k-j]+mod)%mod; } for(int j=1;j<=n;j++) x[j]+=dx; for(int j=1;j<=n;j++) y[j]+=dy; } cout<<ans; 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...