結果
問題 | No.707 書道 |
ユーザー |
|
提出日時 | 2020-08-24 12:15:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 2,000 ms |
コード長 | 839 bytes |
コンパイル時間 | 2,253 ms |
コンパイル使用メモリ | 194,812 KB |
最終ジャッジ日時 | 2025-01-13 13:17:45 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define REP(i,n) for(int i=0; i<(int)(n); i++)#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)#define ALL(x) (x).begin(), (x).end()const double PI = acos(-1);double calc(int y, int x, const vector<string> &bd) {double ret = 0;REP (i, bd.size()) REP (j, bd[i].size()) {if (bd[i][j] == '1')ret += hypot(y - i, x - j);}return ret;}int main() {ios_base::sync_with_stdio(0);cin.tie(0);int h, w;cin >> h >> w;vector<string> bd(h);REP (i, h) cin >> bd[i];double ret = 1e100;REP (i, w) {ret = min(ret, calc(-1, i, bd));ret = min(ret, calc(h, i, bd));}REP (i, h) {ret = min(ret, calc(i, -1, bd));ret = min(ret, calc(i, w, bd));}cout << fixed << setprecision(12) << ret << endl;return 0;}