結果

問題 No.707 書道
ユーザー 0x19f0x19f
提出日時 2018-06-29 22:56:44
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 747 bytes
コンパイル時間 1,577 ms
コンパイル使用メモリ 149,636 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 15:32:18
合計ジャッジ時間 1,772 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 - x) * (i - x) + (j - y) * (j - y));
      }
    }
    ans = min(ans, t);
  }
  printf("%.15lf\n", ans);
}
0