题面
题解
我们枚举一下发射源,并把敌人和激光塔按极角排序,那么一组合法解就是两个极角之差不超过(pi)且中间有敌人的三元组数,预处理一下前缀和然后用双指针就行了
//minamoto
#include<bits/stdc++.h>
#define R register
#define ll long long
#define inline __inline__ __attribute__((always_inline))
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
R int res,f=1;R char ch;
while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
return res*f;
}
const int N=3205;
struct node{
int x,y,t;
inline node(){}
inline node(R int xx,R int yy,R int tt):x(xx),y(yy),t(tt){}
inline ll operator *(const node &b)const{return 1ll*x*b.y-1ll*y*b.x;}
inline bool sgn()const{return x?x>0:y>0;}
inline bool operator <(const node &b)const{
return sgn()!=b.sgn()?sgn()<b.sgn():*this*b<0;
}
}a[N],b[N],c[N],st[N];
ll res;int s[N],f[N],g[N],D,S,T,top;
int main(){
// freopen("testdata.in","r",stdin);
D=read();
fp(i,1,D)a[i].x=read(),a[i].y=read();
S=read();
fp(i,1,S)b[i].x=read(),b[i].y=read();
T=read();
fp(i,1,T)c[i].x=read(),c[i].y=read();
fp(k,1,S){
top=0;
fp(i,1,D)st[++top]=node(a[i].x-b[k].x,a[i].y-b[k].y,0);
fp(i,1,T)st[++top]=node(c[i].x-b[k].x,c[i].y-b[k].y,1);
sort(st+1,st+1+top);
fp(i,1,top)st[top+i]=st[i];
fp(i,1,top<<1){
s[i]=s[i-1],f[i]=f[i-1],g[i]=g[i-1];
st[i].t?++f[i],g[i]+=s[i]:++s[i];
}
for(R int i=1,j=1;i<=top;++i)if(st[i].t){
if(j<i)j=i;
while(j+1<i+top&&st[i]*st[j+1]<=0)++j;
res+=g[j]-g[i]-s[i]*(f[j]-f[i]);
}
}
printf("%lld
",res);
return 0;
}