結果
| 問題 | No.707 書道 | 
| コンテスト | |
| ユーザー |  a01sa01to | 
| 提出日時 | 2025-06-12 00:02:47 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 818 bytes | 
| コンパイル時間 | 4,252 ms | 
| コンパイル使用メモリ | 282,692 KB | 
| 実行使用メモリ | 7,844 KB | 
| 最終ジャッジ日時 | 2025-06-12 00:02:52 | 
| 合計ジャッジ時間 | 4,718 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 6 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  vector Grid(h, vector<char>(w));
  rep(i, h) rep(j, w) cin >> Grid[i][j];
  double ans = 1e18;
  for (int x = -1; x <= h; ++x) {
    for (int y = -1; y <= w; ++y) {
      if (!(x == -1 || x == h || y == -1 || y == w)) continue;
      double sum = 0;
      rep(i, h) rep(j, w) {
        double d = sqrt((x - i) * (x - i) + (y - j) * (y - j));
        if (Grid[i][j] == '1') sum += d;
      }
      ans = min(ans, sum);
    }
  }
  cout << fixed << setprecision(15) << ans << '\n';
  return 0;
}
            
            
            
        