結果
問題 | No.707 書道 |
ユーザー |
|
提出日時 | 2019-09-21 22:40:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 721 bytes |
コンパイル時間 | 1,413 ms |
コンパイル使用メモリ | 171,288 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 03:10:26 |
合計ジャッジ時間 | 1,873 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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);}