結果
問題 | No.707 書道 |
ユーザー |
![]() |
提出日時 | 2018-06-29 23:02:23 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 744 bytes |
コンパイル時間 | 1,491 ms |
コンパイル使用メモリ | 164,460 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-01 00:08:53 |
合計ジャッジ時間 | 1,867 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 |
ソースコード
#include <bits/stdc++.h>#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)using namespace std;typedef long long ll;int main(void) {ll H, W;cin >> H >> W;vector<vector<ll>> P(H + 1, vector<ll>(W + 1));REP(i, 1, H + 1) {string s; cin >> s;REP(j, 1, W + 1) {P[i][j] = s[j - 1] - '0';}}double ans = 1e20;REP(i, 0, H + 2) REP(j, 0, W + 2) {ll cnt = 0;if(i == 0) cnt++;if(i == H + 1) cnt++;if(j == 0) cnt++;if(j == W + 1) cnt++;if(cnt != 1) continue;double t = 0;REP(y, 1, H + 1) REP(x, 1, W + 1) {if(P[y][x] == 1) {t += sqrt((i - y) * (i - y) + (j - x) * (j - x));}}ans = min(ans, t);}printf("%.15lf\n", ans);}