1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
| #include <set> #include <map> #include <queue> #include <stack> #include <deque> #include <cmath> #include <bitset> #include <cstdio> #include <vector> #include <string> #include <complex> #include <utility> #include <cstring> #include <iostream> #include <assert.h> #include <algorithm>
using namespace std; #define FO(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout) #define ll long long #define ull unsigned ll #define db double #define lb long db #define pb push_back #define com complex<db> #define mp(x,y) make_pair((x),(y)) #define fi first #define se second #define all(x) (x).begin(),(x).end() #define cle(x) memset(x,0,sizeof(x)) #define lowbit(x) ((x)&(-(x))) #define bit(x,i) (((x)>>(i))&1) #define Abs(x) ((x)>0?(x):-(x)) #define fo(i,j,k) for(int i=(j),end_i=(k);i<=end_i;i++) #define fd(i,j,k) for(int i=(j),end_i=(k);i>=end_i;i--) inline ll read() { ll x=0; char ch=getchar(); bool f=0; for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=1; for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<3)+(x<<1)+(ch^48); return f?-x:x; } #define CASET fo(___,1,read()) const int N=3005;
struct point{ ll x,y; friend inline bool operator<(const point &A,const point &B) { if(A.x!=B.x) return A.x<B.x; return A.y<B.y; } friend inline point operator-(const point &A,const point &B) { return (point){A.x-B.x,A.y-B.y}; } }; inline ll cross(const point &A,const point &B) { return A.x*B.y-B.x*A.y; } inline ll area2(const point &A,const point &B,const point &C) { return Abs(cross(A-B,A-C)); } point p[N]; struct line{ int i,j; db ang; friend inline bool operator<(const line &A,const line &B) { return A.ang<B.ang; } };
line a[N*N]; int n,m,id[N],pos[N];
ll solve(ll S) { ll sum=0; fo(i,1,n) pos[i]=id[i]=i; int x,y,l,r,mid,ans; fo(i,1,m) { x=a[i].i, y=a[i].j; if(pos[x]>pos[y]) swap(x,y); l=1; r=pos[x]; for(;l+1<r;) { mid=l+r>>1; if(area2(p[x],p[y],p[id[mid]])<=S) r=mid; else l=mid; } if(r>=2&&area2(p[x],p[y],p[id[r-1]])<=S) r--; sum+=pos[x]-r; l=pos[y]; r=n; for(;l+1<r;) { mid=l+r>>1; if(area2(p[x],p[y],p[id[mid]])<=S) l=mid; else r=mid; } if(l<n&&area2(p[x],p[y],p[id[l+1]])<=S) l++; sum+=l-pos[y];
swap(pos[x],pos[y]); swap(id[pos[x]],id[pos[y]]); } return sum; } ll L,R; int main() { n=read(); L=read(); R=read(); fo(i,1,n) p[i].x=read(),p[i].y=read(); sort(p+1,p+n+1); fo(i,1,n) fo(j,i+1,n) a[++m]=(line){i,j,atan2(p[j].y-p[i].y,p[j].x-p[i].x)}; sort(a+1,a+m+1); printf("%lld\n",(solve(R*2)-solve(L*2-1))/3); return 0; }
|