結果
問題 |
No.707 書道
|
ユーザー |
![]() |
提出日時 | 2020-03-15 13:35:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 2,000 ms |
コード長 | 730 bytes |
コンパイル時間 | 2,830 ms |
コンパイル使用メモリ | 195,716 KB |
最終ジャッジ日時 | 2025-01-09 06:56:37 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 |
ソースコード
#include<bits/stdc++.h> using lint=long long; int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); std::vector<std::pair<double,double>>a; lint h,w;std::cin>>h>>w; for(lint i=1;i<=h;i++){ for(lint j=1;j<=w;j++){ char c;std::cin>>c; if(c=='1')a.emplace_back(i,j); } } double ans=std::numeric_limits<double>::infinity(); for(lint i=0;i<=h+1;i++){ for(lint j=0;j<=w+1;j++){ if((1<=i&&i<=h)==(1<=j&&j<=w))continue; double now=0; for(auto[x,y]:a){ now+=std::hypot(x-i,y-j); } if(now<ans)ans=now; } } std::cout<<std::setprecision(12)<<ans<<'\n'; }