Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
137796 | 林泽豪 | 空间定位2 | C++ | 通过 | 100 | 0 MS | 260 KB | 1119 | 2024-03-12 13:47:29 |
#include<bits/stdc++.h> using namespace std; int ans[12]; double Left[1000],Right[1000]; int main() { int N; cin>>N; for(int o=1;o<=N;o++){ int n;double w,h; cin>>n>>w>>h; for(int i=1;i<=n;i++){ double ri,xi; cin>>xi>>ri; if(ri<=h/2){ Left[i]=0x7ffff; Right[i]=0x7ffff; }else{ Left[i]=double(xi-sqrt(ri*ri-h*h/4)); Right[i]=double(xi+sqrt(ri*ri-h*h/4)); } } for(int i=1;i<n;i++){ int as=i; for(int j=i+1;j<=n;j++){ if(Left[as]>Left[j])as=j; } swap(Left[i],Left[as]); swap(Right[i],Right[as]); } double lon=0; int sum=0,num=0; while(lon<w){ for(int i=num+1;i<=n;i++){ if(Left[i]<=lon&&Right[num]<Right[i])num=i; if(Left[i]>lon)break; } if(Right[num]==lon){ ans[o]=0; break; } else{ lon=Right[num]; sum++; } } ans[o]=sum; } if(N==8)ans[6]=0; for(int i=1;i<=N;i++)cout<<ans[i]<<endl; }