結果
問題 | No.707 書道 |
ユーザー |
![]() |
提出日時 | 2020-11-14 12:39:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 687 bytes |
コンパイル時間 | 1,658 ms |
コンパイル使用メモリ | 171,220 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-22 22:48:57 |
合計ジャッジ時間 | 2,251 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | AC * 1 WA * 5 |
ソースコード
#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; }