Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
137787 吴松韬 空间定位2 C++ 解答错误 25 0 MS 260 KB 1070 2024-03-12 13:40:31

Tests(1/4):


#include<bits/stdc++.h> using namespace std; int m,n,w,h; int flaga,flagb,flagc; int maxx; 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; // } if(l[1].left<=0){ flagc=1; } maxx=1; for(int j=1;j<=n;j++){ if(l[j].right>=l[j+1].left){ flaga++; } if(l[j].right>=w){ flagb++; if(l[j].right>l[maxx].right){ maxx=j; } } } if((flaga==n) and (flagb>0) and (flagc==1)){ cout<<maxx<<endl; }else{ cout<<0<<endl; } } }


测评信息: