提交时间:2024-03-12 13:55:35

运行 ID: 137808

#include<bits/stdc++.h> using namespace std; int m,n,w,h; int flaga,flagb,flagc; int maxx; double sum,L,R; struct Location{ double r; double x; double left; double right; }l[10005]; double G(double a,int b){ double c=b; c/=2; if(a<=c){ return 0; }else{ return sqrt(pow(a,2)-pow(c,2)); } } bool wdnmd(Location x,Location y){ if(x.left<y.left){ return true; }else{ return false; } } int main(){ cin>>m; for(int i=1;i<=m;i++){ cin>>n>>w>>h; flaga=0; flagb=0; flagc=0; for(int j=1;j<=n;j++){ cin>>l[j].x>>l[j].r; l[j].left=l[j].x-G(l[j].r,h); l[j].right=l[j].x+G(l[j].r,h); } sort(l+1,l+n+1,wdnmd); // for(int k=1;k<=n;k++){ // cout<<l[k].left<<endl; // } sum=0; L=w; R=0; for(int k=1;k<=n;k++){ if(l[k].right>R and l[k].left<L){ sum=1; R=l[k].right; L=l[k].left; }else if(l[k].right>R and !l[k].left<L){ sum++; R=l[k].right; }else if(!l[k].right>R and l[k].left<L){ sum++; L=l[k].left; } } if(R>=w and L<=0){ cout<<sum<<endl; }else{ cout<<0<<endl; } } }