結果

問題 No.707 書道
ユーザー SSRSSSRS
提出日時 2020-11-14 12:39:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 687 bytes
コンパイル時間 1,611 ms
コンパイル使用メモリ 168,712 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-30 04:52:15
合計ジャッジ時間 2,316 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const double INF = 10000000;
int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<int>> P(H, vector<int>(W));
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> P[i][j];
    }
  }
  double ans = INF;
  for (int i = -1; i <= H; i++){
    for (int j = -1; j <= W; j++){
      if (0 <= i && i < H && 0 <= j && j < W){
        double sum = 0;
        for (int y = 0; y < H; y++){
          for (int x = 0; x < W; x++){
            if (P[y][x] == 1){
              sum += sqrt(pow(y - i, 2) + pow(x - j, 2));
            }
          }
        }
        ans = min(ans, sum);
      }
    }
  }
  cout << ans << endl;
}
0