結果
| 問題 |
No.707 書道
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-03 00:03:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 798 bytes |
| コンパイル時間 | 2,006 ms |
| コンパイル使用メモリ | 197,340 KB |
| 最終ジャッジ日時 | 2025-02-07 20:43:33 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
int H,W; cin >> H >> W;
vector<string> P(H);
rep(i,H) cin >> P[i];
using ld = long double;
ld ans = 1e18;
for(int x = 0; x <= H + 1; x++) {
for(int y = 0; y <= W + 1; y++) {
int cnt = (x == 0) + (x == H + 1) + (y == 0) + (y == W + 1);
if(cnt == 1) {
ld cost = 0;
rep(i,H)rep(j,W)if(P[i][j] == '1') {
cost += sqrtl((x - (i+1)) * (x - (i+1)) + (y - (j+1)) * (y - (j+1)));
}
ans = min(ans, cost);
}
}
}
cout << fixed << setprecision(20) << ans << endl;
}