This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<vector>
using namespace std;
#define INF 100000000;
typedef pair<int,int> point;
bool acute(point a, point b, point c){
a.first-=b.first;
c.first-=b.first;
a.second-=b.second;
c.second-=b.second;
if(a.first*c.second+a.second*c.first>=0)return true;
return false;
}
double area(point a, point b, point c){
double area=a.first*b.second+b.first*c.second+c.first*a.second-a.second*b.first-b.second*c.first-c.second*a.first;
if(area<0)area=-area;
return area;
}
double distpp(point a, point b){
double ans=(a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second);
ans=sqrt(ans);
return ans;
}
double distpl(point a, point b, point c){
if(acute(a,b,c)){
if(acute(a,c,b)){
double area=a.first*b.second+b.first*c.second+c.first*a.second-a.second*b.first-b.second*c.first-c.second*a.first;
if(area<0)area=-area;
//cout<<area<<endl;
return area/distpp(b,c);
}
return distpp(a,c);
}
return distpp(a,b);
}
int main(){
int n,s;
cin>>n>>s;
int fences[n][4];
for(int i=0;i<n;i++)cin>>fences[i][0]>>fences[i][1]>>fences[i][2]>>fences[i][3];
double d=8*s;
vector<pair<int,int> >points;
points.push_back(pair<int,int>(-s,-s));
points.push_back(pair<int,int>(-s,+s));
points.push_back(pair<int,int>(+s,+s));
points.push_back(pair<int,int>(+s,-s));
for(int i=0;i<4;i++){
int next=(i+1)%4;
double can=6*s;
can+=distpl(points[i],pair<int,int>(fences[0][0],fences[0][1]),pair<int,int>(fences[0][2],fences[0][3]));
can+=distpl(points[next],pair<int,int>(fences[0][0],fences[0][1]),pair<int,int>(fences[0][2],fences[0][3]));
d=min(d,can);
//cout<<can<<endl;
}
vector<pair<double,int> >v;
int maximo=0;
/*for(int i=0;i<4;i++){
if(area(points[ma],pair<int,int>(fences[i][0],fences[i][1]),pair<int,int>(fences[i][2],fences[i][3]))<area(points[i],pair<int,int>(fences[i][0],fences[i][1]),pair<int,int>(fences[i][2],fences[i][3]))){
}
}*/
cout<<d<<endl;
return 0;
}
Compilation message (stderr)
fences.cpp: In function 'int main()':
fences.cpp:59:6: warning: unused variable 'maximo' [-Wunused-variable]
int maximo=0;
^~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |