#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++) #define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--) #define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--) #define fi first #define se second #define vi vector #define pb push_back #define mp make_pair #define pcnt __builtin_popcount typedef long long ll; const double inf = 900900900100.0; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> h >> w; string s[55] = {}; double madist = inf; rep(y,h) cin >> s[y]; rep(y,h+2)rep(x,w+2){ if(y==h+1&&x==w+1) continue; if(y==0 &&x ==0) continue; if(y==h+1&&x ==0) continue; if(y==0 &&x ==w+1) continue; if(x==0||y==0||x==w+1||y==h+1){ double dist = 0.0; REP(yy,1,h+1)REP(xx,1,w+1){ if(y==yy&&x==xx) continue; if(s[yy-1][xx-1]=='1'){ dist += sqrtl((double)(yy-y)*(yy-y)+(double)(xx-x)*(xx-x)); // cout << dist << endl; } } // cout << dist << endl; madist = min(madist,dist); } } cout <