結果
| 問題 |
No.707 書道
|
| コンテスト | |
| ユーザー |
ats5515
|
| 提出日時 | 2018-06-29 22:28:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,045 bytes |
| コンパイル時間 | 671 ms |
| コンパイル使用メモリ | 89,772 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 23:57:16 |
| 合計ジャッジ時間 | 1,175 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 1 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
double solve(vector<pair<int, int> > &vp, int x, int y) {
double res = 0;
for (int i = 0; i < vp.size(); i++) {
res += sqrt((vp[i].first - x)*(vp[i].first - x) + (vp[i].second - y)*(vp[i].second - y));
}
return res;
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int H, W;
cin >> H >> W;
vector<string> S(H);
double res = 1e18;
vector<pair<int, int> > vp;
for (int i = 0; i < H; i++) {
cin >> S[i];
for (int j = 0; j < W; j++) {
if (S[i][j] == '1') {
vp.emplace_back(i + 1, j + 1);
}
}
}
for (int i = 0; i < H; i++) {
res = min(res, solve(vp, i, 0));
res = min(res, solve(vp, i, W + 1));
}
for (int i = 0; i < W; i++) {
res = min(res, solve(vp, H + 1, i));
res = min(res, solve(vp, 0, i));
}
cout << fixed << setprecision(15) << res << endl;
}
ats5515