diff --git a/src/P1522/P1522.cpp b/src/P1522/P1522.cpp index 45bcb1a..00d7868 100644 --- a/src/P1522/P1522.cpp +++ b/src/P1522/P1522.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #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::max(), double_min = std::numeric_limits::min(); -double min_ans = std::numeric_limits::max(); +const double double_max = std::numeric_limits::max(), double_min = std::numeric_limits::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<