結果

問題 No.707 書道
ユーザー ngtkanangtkana
提出日時 2020-03-15 13:22:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 707 bytes
コンパイル時間 2,135 ms
コンパイル使用メモリ 202,788 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-16 10:12:05
合計ジャッジ時間 2,773 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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<<ans<<'\n';
}
0