結果
| 問題 | No.707 書道 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-21 22:40:11 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 721 bytes |
| 記録 | |
| コンパイル時間 | 1,808 ms |
| コンパイル使用メモリ | 186,200 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-07 08:09:22 |
| 合計ジャッジ時間 | 1,838 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int h, w;
cin>>h>>w;
string s[h];
for (int i=0; i<h; i++) cin>>s[i];
vector<pair<int, int> > ps;
for (int i=1; i<=w; i++) {
ps.push_back(make_pair(0, i));
ps.push_back(make_pair(h+1, i));
}
for (int i=1; i<=h; i++) {
ps.push_back(make_pair(i, 0));
ps.push_back(make_pair(i, w+1));
}
double ans = 1e14;
for (auto p: ps) {
int y = p.first;
int x = p.second;
double tmp = 0.0;
for (int i=0; i<h; i++) {
for (int j=0; j<w; j++) {
if (s[i][j] == '1') {
tmp += sqrt(pow(y - i - 1, 2) + pow(x - j - 1, 2));
}
}
}
ans = min(tmp, ans);
}
printf("%.6lf\n", ans);
}