結果

問題 No.707 書道
ユーザー ei1333333ei1333333
提出日時 2018-06-29 22:28:50
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 869 bytes
コンパイル時間 1,921 ms
コンパイル使用メモリ 201,704 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-13 15:21:31
合計ジャッジ時間 2,521 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;


int main() {
  int H, W;
  string P[55];

  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    string s;
    cin >> s;

    string ret = "o";
    ret += s;
    ret += "o";
    P[i + 1] = ret;
  }
  P[0] = P[H + 1] = "x";
  for(int i = 0; i < W; i++) {
    P[0] += "o";
    P[H + 1] += "o";
  }
  P[0] += "x";
  P[H + 1] += "x";

  double ret = 1e9;
  for(int i = 0; i < H + 2; i++) {
    for(int j = 0; j < W + 2; j++) {
      if(P[i][j] == 'o') {
        double cost = 0;
        for(int k = 0; k < H + 2; k++) {
          for(int l = 0; l < W + 2; l++) {
            if(P[k][l] == '1') {
              cost += sqrt((i - k) * (i - k) + (j - l) * (j - l));
            }
          }
        }
        ret = min(ret, cost);
      }
    }
  }
  cout << fixed << setprecision(10) << ret << endl;
}
0