From f9e10f2f9ac3b9d2f0c4f17d4df25103e2acaa11 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Wed, 9 Oct 2024 21:56:57 +0800 Subject: [PATCH] update --- src/P1522/P1522.cpp | 83 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 src/P1522/P1522.cpp diff --git a/src/P1522/P1522.cpp b/src/P1522/P1522.cpp new file mode 100644 index 0000000..4d14fca --- /dev/null +++ b/src/P1522/P1522.cpp @@ -0,0 +1,83 @@ +#include +#include +#include +#include + +#define NV(v)#v<<" : "<<(v) + +using ull = unsigned long long; +const size_t max_n = 150+5; +struct Point{ + ull x,y; +}; +ull n; +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(); + +double len(const Point &p1, const Point &p2){ + return std::sqrt( + std::pow((double)p1.x-(double)p2.x, (double)2)+ + std::pow((double)p1.y-(double)p2.y,(double)2) + ); +} + +int main(){ + // std::cout<>n; + + for(ull i = 1;i<=n;i++){ + std::cin>>points[i].x>>points[i].y; + } + + for(ull i=1;i<=n;i++){ + std::cin>>s; + for(ull j=1;j<=n;j++){ + if(s[j-1]=='1'){ + mtx_len[i][j] = len(points[i],points[j]); + }else{ + mtx_len[i][j] = double_inf; + } + } + } + for(ull k=1;k<=n;k++){ + 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){ + new_len = mtx_len[i][k]+mtx_len[k][j]; + }else{ + continue; + } + if(new_len