之前也有帖子提到过直接判断四个角是否可行的居然也过了这道题,那么以下数据理论上来讲是过不了的
5 100
0.000 100.000
100.000 100.000
0.000 0.000
100.000 0.000
50.000 50.000
该数据将屏蔽器安装在角落上,但是实际上是有解的。
由于不知道此题 SPJ 如何工作,因此不知道输出文件是什么。
至少这份我写的 AC 代码被卡掉了:
#include<bits/stdc++.h>
using namespace std;
double x[100001],y[100001];
int main()
{
ios::sync_with_stdio(false);
int n,l;
srand(time(0));
cin>>n>>l;
for(int i=1;i<=n;i++){
cin>>x[i]>>y[i];
}
double dis=1.0*l/n+1e-6;
if(1){
double tx=0,ty=0;
bool flag=0;
for(int i=1;i<=n;i++){
if((x[i]-tx)*(x[i]-tx)+(y[i]-ty)*(y[i]-ty)<dis*dis){
flag=1;
break;
}
}
if(!flag){
cout<<fixed<<setprecision(6)<<tx<<" "<<ty;
return 0;
}
tx=0,ty=l;
flag=0;
for(int i=1;i<=n;i++){
if((x[i]-tx)*(x[i]-tx)+(y[i]-ty)*(y[i]-ty)<dis*dis){
flag=1;
break;
}
}
if(!flag){
cout<<fixed<<setprecision(6)<<tx<<" "<<ty;
return 0;
}
tx=l,ty=0;
flag=0;
for(int i=1;i<=n;i++){
if((x[i]-tx)*(x[i]-tx)+(y[i]-ty)*(y[i]-ty)<dis*dis){
flag=1;
break;
}
}
if(!flag){
cout<<fixed<<setprecision(6)<<tx<<" "<<ty;
return 0;
}
tx=l,ty=l;
flag=0;
for(int i=1;i<=n;i++){
if((x[i]-tx)*(x[i]-tx)+(y[i]-ty)*(y[i]-ty)<dis*dis){
flag=1;
break;
}
}
if(!flag){
cout<<fixed<<setprecision(6)<<tx<<" "<<ty;
return 0;
}
cout<<"GG\n";
return 0;
}
// while(0){
// double tx=(1ull*rand()*rand()%l+1)*1.0*(1ull*rand()*rand()%1000000)/1000000;
// double ty=(1ull*rand()*rand()%l+1)*1.0*(1ull*rand()*rand()%1000000)/1000000;
//
// }
return 0;
}
(由于是从随机化改过来的,所以有点丑)