結果
問題 | No.707 書道 |
ユーザー |
![]() |
提出日時 | 2018-06-29 23:06:40 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 836 bytes |
コンパイル時間 | 1,189 ms |
コンパイル使用メモリ | 162,260 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-01 00:11:13 |
合計ジャッジ時間 | 1,700 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 |
ソースコード
#include "bits/stdc++.h"using namespace std;typedef long long ll;#define rep(i,l,r) for(int i=(l);i<(r);i++)#define fcout cout << fixed << setprecision(10)int h,w;double paint(int a,int b,array<array<bool,51>,51> p){double ans=0;rep(i,1,h+1)rep(j,1,w+1)if(p[i][j])ans+=sqrt((a-i)*(a-i)+(b-j)*(b-j));return ans;}int main(){cin>>h>>w;array<array<bool,51>,51> p;string s;rep(i,1,h+1){cin>>s;rep(j,1,w+1)p[i][j]=s[j-1]-'0';}double mn=1e20,sum;rep(i,1,h+1){sum=paint(i,0,p);if(sum<mn)mn=sum;}rep(i,1,h+1){sum=paint(i,w+1,p);if(sum<mn)mn=sum;}rep(i,1,w+1){sum=paint(0,i,p);if(sum<mn)mn=sum;}rep(i,1,w+1){sum=paint(h+1,i,p);if(sum<mn)mn=sum;}fcout<<mn;}