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
|
#define ts cout<<"ok"<<endl #define ll long long #define hh puts("") #define time TTTT using namespace std; int n,m,s,lim,head[1005],vis[305],match[505]; int cnt,time,ans; struct { int v,nx; }e[100005]; struct node{ int x,y; }peo[10005],tx[10005]; inline int read(){ int ret=0,ff=1;char ch=getchar(); while(!isdigit(ch)){if(ch=='-') ff=-ff;ch=getchar();} while(isdigit(ch)){ret=ret*10+(ch^48);ch=getchar();} return ret*ff; } inline void add(int x,int y){ e[++cnt].v=y; e[cnt].nx=head[x]; head[x]=cnt; } inline int dis(int x,int y){ return abs(peo[x].x-tx[y].x)+abs(peo[x].y-tx[y].y); } bool find(int x){ for(int i=head[x];i;i=e[i].nx){ int v=e[i].v; if(vis[v]==time) continue; vis[v]=time; if(!match[v]||find(match[v])){ match[v]=x; return 1; } } return 0; } signed main(){ int T=read(); while(T--){ memset(head,0,sizeof(head)); memset(vis,0,sizeof(vis)); memset(match,0,sizeof(match)); cnt=0,time=0,ans=0; n=read(),m=read(); s=read(),lim=read(); lim=s*lim; for(int i=1;i<=n;i++){ peo[i].x=read(); peo[i].y=read(); } for(int i=1;i<=m;i++){ tx[i].x=read(); tx[i].y=read(); } for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(dis(i,j)*200<=lim) add(i,j); for(int i=1;i<=n;i++){ time++; ans+=find(i); } printf("%dn",ans); } return 0; }
|
近期评论