update
This commit is contained in:
parent
576b97f16d
commit
569e030b48
@ -6,7 +6,6 @@
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <bitset>
|
||||
|
||||
#define NV(v)#v<<" : "<<(v)
|
||||
#ifdef NDEBUG
|
||||
@ -25,8 +24,8 @@ Point points[max_n];
|
||||
std::string s;
|
||||
double mtx_len[max_n][max_n];
|
||||
double max_len[max_n];
|
||||
const double double_inf = std::numeric_limits<double>::max(), double_min = std::numeric_limits<double>::min();
|
||||
double min_ans = std::numeric_limits<double>::max();
|
||||
const double double_max = std::numeric_limits<double>::max(), double_min = std::numeric_limits<double>::min();
|
||||
double min_ans {double_max}, default_ans{double_min};
|
||||
|
||||
double len(const Point &p1, const Point &p2){
|
||||
return std::sqrt(
|
||||
@ -51,8 +50,9 @@ int main(){
|
||||
}
|
||||
if(s[j-1]=='1'){
|
||||
mtx_len[i][j] = len(points[i],points[j]);
|
||||
default_ans = std::max(default_ans,mtx_len[i][j]);
|
||||
}else{
|
||||
mtx_len[i][j] = double_inf;
|
||||
mtx_len[i][j] = double_max;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -60,7 +60,7 @@ int main(){
|
||||
for(ull i=1;i<=n;i++){
|
||||
for(ull j=1;j<=n;j++){
|
||||
double new_len;
|
||||
if(mtx_len[i][k]!=double_inf && mtx_len[k][j]!=double_inf){
|
||||
if(mtx_len[i][k]!=double_max && mtx_len[k][j]!=double_max){
|
||||
new_len = mtx_len[i][k]+mtx_len[k][j];
|
||||
}else{
|
||||
continue;
|
||||
@ -74,10 +74,10 @@ int main(){
|
||||
}
|
||||
|
||||
for(ull i=1;i<=n;i++){
|
||||
max_len[i]=double_inf;
|
||||
max_len[i]=double_max;
|
||||
for(ull j=1;j<=n;j++){
|
||||
if(mtx_len[i][j]==double_inf)continue;
|
||||
max_len[i] = std::max(mtx_len[i][j],(max_len[i]==double_inf?double_min:max_len[i]));
|
||||
if(mtx_len[i][j]==double_max)continue;
|
||||
max_len[i] = std::max(mtx_len[i][j],(max_len[i]==double_max?double_min:max_len[i]));
|
||||
}
|
||||
}
|
||||
DEBUG(
|
||||
@ -85,7 +85,7 @@ int main(){
|
||||
)
|
||||
for(ull i=1;i<=n;i++){
|
||||
for(ull j=i+1;j<=n;j++){
|
||||
if(mtx_len[i][j]==double_inf){
|
||||
if(mtx_len[i][j]==double_max){
|
||||
DEBUG(
|
||||
std::cout<<NV(i)<<'\n'<<NV(j)<<'\n'<<NV(max_len[i])<<'\n'<<NV(max_len[j])<<'\n'
|
||||
<<NV(len(points[i], points[j]))<<'\n'<<NV(max_len[i]+ len(points[i], points[j]) + max_len[j])<<'\n';
|
||||
@ -99,5 +99,5 @@ int main(){
|
||||
}
|
||||
}
|
||||
|
||||
std::cout<<std::fixed<<std::setprecision(6)<<min_ans<<'\n';
|
||||
std::cout<<std::fixed<<std::setprecision(6)<<std::max(min_ans, default_ans)<<'\n';
|
||||
}
|
Loading…
Reference in New Issue
Block a user