結果
| 問題 |
No.707 書道
|
| コンテスト | |
| ユーザー |
kyawashell
|
| 提出日時 | 2018-06-29 22:42:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 787 bytes |
| コンパイル時間 | 811 ms |
| コンパイル使用メモリ | 88,784 KB |
| 最終ジャッジ日時 | 2025-01-06 11:41:43 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 |
ソースコード
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
ll h,w;
char in[100][100];
bool p[100][100];
int main() {
cin >> h >> w;
rep(i,h)cin >> in[i];
rep(i,h)rep(j,w) p[i][j] = in[i][j] - '0';
double ans = 1e9;
rep(x1,h+2)rep(y1,w+2) {
double sum = 0;
ll cou = 0;
if(x1 == 0)cou++;
if(x1 == h+1)cou++;
if(y1 == 0)cou++;
if(y1 == w+1)cou++;
if(cou != 1)continue;
for(int x2 = 1;x2 < h+1;x2++) {
for(int y2 = 1;y2 < w+1;y2++) {
if(p[x2 -1][y2-1])sum += sqrt(pow(x1-x2,2) + pow(y1-y2,2));
}
}
ans = min(ans,sum);
}
printf("%.10f\n",ans);
return 0;
}
kyawashell