結果
| 問題 |
No.707 書道
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-29 22:33:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 788 bytes |
| コンパイル時間 | 1,747 ms |
| コンパイル使用メモリ | 170,836 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-30 23:58:23 |
| 合計ジャッジ時間 | 2,211 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
double calc(int x, int y, int H, int W, vector<string>& p) {
double res = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (p[i][j] == '0') continue;
int x2 = j + 1, y2 = i + 1;
res += hypot((x - x2), (y - y2));
}
}
return res;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int H, W;
cin >> H >> W;
vector<string> p(H);
for (int i = 0; i < H; i++) {
cin >> p[i];
}
double ans = 1e15;
for (int i = 0; i < H; i++) {
int y = i + 1;
int x = 0;
ans = min(ans, calc(x, y, H, W, p));
}
cout << fixed << setprecision(15) << ans << endl;
return 0;
}