Problem:
出前配達
フードデリバリーサービス UnterEats では会社のブランド価値と輸送効率を同時に高めるため，世界的デザイナーX氏がデザインした専用の容器で料理を運んでいる．
この素晴らしい容器であるが，実際に使用する配達員たちからの評判は非常に悪かった．取っ手がついていないのだ．配達員たちはちょうどバランスのよいところで容器を下から支えなくてはならず，バランスを崩して料理をダメにしてしまう事故が頻発していた．
UnterEats 社は取っ手をつけようとしたのだが，X氏に相談したところ「私のデザインに誤りがあるはずがない」と逆上され，それでも付けようとすると訴訟をちらつかせてくる始末であった．仕方なく UnterEats 社のソフトウェアエンジニアであるあなたが料理の配置から容器をどこで持てばいいか計算するソフトウェアを開発することとなった．
この容器は正方形の枠が縦
H
行，横
W
列にわたって敷き詰められた形状になっている．上から
i
行目，左から
j
列目の枠に重さ
v
i,j
の料理が入れられているとき，次の条件を満たす実数の組
(r, c)
を求めてほしい．
Σ
i,j
v
i,j
(i-r) = 0
かつ
Σ
i,j
v
i,j
(j-c) = 0
Input
入力は 50 個以下のデータセットからなる． 各データセットは次の形式で表される．
H W
v
1,1
v
1,2
...v
1,W
v
2,1
v
2,2
...v
2,W
…
v
H,1
v
H,2
...v
H,W
1 行目には，容器の大きさを表す 2 つの整数
H
と
W
(
1≤ H,W ≤ 100
) が与えられる．2 行目から
H+1
行目には，各行に数字のみからなる
W
文字の文字列が与えられる．
i+1
行
j
列目の数字が表す数が
v
i,j
(
0≤ v
i,j
≤ 9
)である．それぞれのデータセットについて
v
i,j
の総和は正である．
入力の終わりはスペースで区切られた 2 つのゼロからなる行で表される．
Output
各データセットに対し，
r
と
c
をこの順でスペース区切りで 1 行に出力せよ．
r
,
c
ともに真の解との絶対誤差が
10
-6
以下であるとき，その出力は正解とみなされる．
Sample Input
3 5
11111
11111
11111
3 5
11111
10111
11111
3 5
12345
12345
12345
0 0
Output for the Sample Input
2.0 3.0
2.0000000000 3.0714285714
2.0000000000 3.6666666667

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
using PP = pair<int, P>;
using PLL = pair<ll, ll>;
using PPLL = pair<ll, PLL>;
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define rrep(i, n) for(ll i = n - 1; i >= 0; --i)
#define loop(i, a, b) for(ll i = a; i <= b; ++i)
#define all(v) v.begin(), v.end()
#define nC2(n) n * (n - 1) / 2
constexpr ll INF = 9009009009009009009LL;
constexpr int INF32 = 2002002002;
constexpr ll MOD = 998244353;
constexpr ll MOD107 = 1000000007;

// Linear Algebra ////////////////////////////////////////////////
const double Rad2Deg = 180.0 / M_PI;
const double Deg2Rad = M_PI / 180.0;
//////////////////////////////////////////////////////////////////

int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

template <class T>
inline bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename Container,
          typename = std::enable_if_t<
              !std::is_same_v<Container, std::string> &&
              std::is_convertible_v<decltype(std::declval<Container>().begin()),
                                    typename Container::iterator>>>
ostream &operator<<(ostream &os, const Container &container) {
    auto it = container.begin();
    auto end = container.end();

    if (it != end) {
        os << *it;
        ++it;
    }
	for (; it != end; ++it) {
		os << " " << *it;
	}
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for (size_t i = 0; i < v.size(); ++i) {
        os << v[i];
        if (i != v.size() - 1) os << " ";
    }
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<vector<T>>& vv) {
	for (size_t i = 0; i < vv.size(); ++i) {
		os << vv[i];
		if (i != vv.size() - 1) os << "\n";
    }
    return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	assert(v.size() > 0);
	for (size_t i = 0; i < v.size(); ++i) is >> v[i];
	return is;
}
template <typename T>
istream& operator>>(istream& is, vector<vector<T>>& vv) {
	assert(vv.size() > 0);
	for (size_t i = 0; i < vv.size(); ++i) is >> vv[i];
	return is;
}

struct phash {
	template<class T1, class T2>
    inline size_t operator()(const pair<T1, T2> & p) const {
        auto h1 = hash<T1>()(p.first);
        auto h2 = hash<T2>()(p.second);

		size_t seed = h1 + h2; 
		h1 = ((h1 >> 16) ^ h1) * 0x45d9f3b;
        h1 = ((h1 >> 16) ^ h1) * 0x45d9f3b;
        h1 = (h1 >> 16) ^ h1;
        seed ^= h1 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
		h2 = ((h2 >> 16) ^ h2) * 0x45d9f3b;
        h2 = ((h2 >> 16) ^ h2) * 0x45d9f3b;
        h2 = (h2 >> 16) ^ h2;
        seed ^= h2 + 0x9e3779b9 + (seed << 6) + (seed >> 2);
        return seed;
    }
};





int solve() {
	ll h, w;
	cin >> h >> w;
	if (h == 0 && w == 0)
		return 1;
	vvll weights(h, vll(w));
	rep(y, h) rep(x, w) {
		char c;
		cin >> c;
		weights[y][x] = c - '0';
	}

	double l = -200, r = 200;
	while (abs(r - l) > 0.000000001) {
		double mid = (l + r) / 2;

		double csum = 0;
		rep(y, h) rep(x, w) {
			csum += weights[y][x] * (1 + y - mid);
		}

		if (0 <= csum) {
			l = mid;
		}
		else {
			r = mid;
		}
	}

	cout << fixed << setprecision(10) << l << " ";

	l = -200, r = 200;
	while (abs(r - l) > 0.000000001) {
		double mid = (l + r) / 2;

		double csum = 0;
		rep(y, h) rep(x, w) {
			csum += weights[y][x] * (1 + x - mid);
		}

		if (0 <= csum) {
			l = mid;
		}
		else {
			r = mid;
		}
	}

	cout << fixed << setprecision(10) << l << "\n";

	return 0;
}

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	while (!solve()) {}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3648
final_rank: 10

code_snippet: #include<bits/stdc++.h>
// #include<atcoder/all>
// #include<boost/multiprecision/cpp_int.hpp>

using namespace std;
// using namespace atcoder;
// using bint = boost::multiprecision::cpp_int;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<ll,ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ve = vector<vector<int>>;
using vb = vector<bool>;
using vvb = vector<vb>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define sz(c) ((ll)(c).size())
#define LB(A,x) (int)(lower_bound(A.begin(),A.end(),x)-A.begin())
#define UB(A,x) (int)(upper_bound(A.begin(),A.end(),x)-A.begin())
// #define MOD 1000000007
#define MOD 998244353
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<typename T>ostream&operator<<(ostream&os,vector<T>&v){for(int i = 0;i < v.size();i++)os<<v[i]<<(i+1!=v.size()?" ":"");return os;}
template<typename T>istream&operator>>(istream&is,vector<T>&v){for(T&in:v)is>>in;return is;}
template<typename T1,typename T2>ostream&operator<<(ostream&os,pair<T1,T2>&p){os<<p.first<<" "<<p.second;return os;}
template<typename T1,typename T2>istream&operator>>(istream&is,pair<T1,T2>&p){is>>p.first>>p.second;return is;}
template<typename T> inline bool chmax(T &a,T b){if(a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a,T b){if(a > b){a = b;return true;}return false;}
ld dist(ld x1,ld y1,ld x2, ld y2){return sqrtl((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}



int main(){
  
  ios_base::sync_with_stdio(0), cin.tie(0);
  while(1){
    int h,w;cin >> h >> w;
    if(!h && !w)break;
    vector<string> v(h);
    cin >> v;
    double l = 0,r = 100;
    int T = 100;
    while(T--){
      double mid = (l + r)/2;
      double sm = 0;
      rep(i,h)rep(j,w){
        sm += (v[i][j]-'0')*(i-mid);
      }
      if(sm >= 0)l = mid;
      else r = mid;
    }
    pair<double,double> res;
    res.first = l+1;
    l = 0,r = 100;
    T = 100;
    while(T--){
      double mid = (l + r)/2;
      double sm = 0;
      rep(i,h)rep(j,w){
        sm += (v[i][j]-'0')*(j-mid);
      }
      if(sm >= 0)l = mid;
      else r = mid;
    }
    res.second = l+1;
    cout << fixed << setprecision(20);
    cout << res << "\n";
  }
  

  return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3508
final_rank: 4

code_snippet: #include <iostream>
#include <vector>
#include <iomanip>
using i64 = long long;
int main()
{
    int H, W;
    while (std::cin >> H >> W, H > 0 && W > 0)
    {
        std::vector<std::vector<i64>> v(H, std::vector<i64>(W));
        for (int i = 0; i < H; i++)
        {
            std::string s;
            std::cin >> s;
            for (int j = 0; j < W; j++)
            {
                v[i][j] = s[j] - '0';
            }
        }
        double x, y;
        {
            auto func = [&v, &H, &W](double x)
            {
                double s = 0;
                for (int i = 0; i < H; i++)
                {
                    for (int j = 0; j < W; j++)
                    {
                        s += v[i][j] * (x - i);
                    }
                }
                return std::abs(s);
            };
            double L = 0;
            double R = H;
            for (int c = 0; c < 200; c++)
            {
                double A = (L * 2 + R) / 3;
                double B = (L + R * 2) / 3;
                if (func(A) < func(B))
                {
                    R = B;
                }
                else
                {
                    L = A;
                }
            }
            x = L;
        }
        {
            auto func = [&v, &H, &W](double y)
            {
                double s = 0;
                for (int i = 0; i < H; i++)
                {
                    for (int j = 0; j < W; j++)
                    {
                        s += v[i][j] * (y - j);
                    }
                }
                return std::abs(s);
            };
            double L = 0;
            double R = W;
            for (int c = 0; c < 200; c++)
            {
                double A = (L * 2 + R) / 3;
                double B = (L + R * 2) / 3;
                if (func(A) < func(B))
                {
                    R = B;
                }
                else
                {
                    L = A;
                }
            }
            y = L;
        }
        std::cout << std::fixed << std::setprecision(10) << x + 1 << " " << y + 1 << std::endl;
    }
}
accuracy: 1
time_ms: 150
memory_kb: 3640
final_rank: 16

code_snippet: #include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
    while (true) {
        int n, m;
        cin >> n >> m;
        if (n == 0) {
            break;
        }
        vector digits(n, vector(m, 0));
        for (auto& i : digits) {
            string s;
            cin >> s;
            for (int j = 0; j < m; ++j) {
                i[j] = s[j] - '0';
            }
        }
        const auto get_x = [&](double x) {
            double sum = 0;
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    sum += (x - (i + 1)) * digits[i][j];
                }
            }
            return sum;
        };
        const auto get_y = [&](double y) {
            double sum = 0;
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    sum += (y - (j + 1)) * digits[i][j];
                }
            }
            return sum;
        };

        const auto binary_search =
            [&](double l, double r, const auto& eval, int iters) {
                for (int i = 0; i < iters; ++i) {
                    double mid = (l + r) / 2;
                    if (eval(mid)) {
                        l = mid;
                    } else {
                        r = mid;
                    }
                }
                return l;
            };

        auto ans_x = binary_search(
            0, n, [&](double x) { return get_x(x) < 0; }, 100
        );
        auto ans_y = binary_search(
            0, m, [&](double y) { return get_y(y) < 0; }, 100
        );

        cout << fixed << setprecision(9) << ans_x << ' ' << ans_y << '\n';
    }
}
accuracy: 1
time_ms: 40
memory_kb: 3528
final_rank: 8

code_snippet: #include <bits/stdc++.h>
//#include "atcoder/all"
using namespace std;
//using namespace atcoder;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
#define all(x) (x).begin(), (x).end()
#define rep1(a)          for(ll i = 0; i < a; i++)
#define rep2(i, a)       for(ll i = 0; i < a; i++)
#define rep3(i, a, b)    for(ll i = a; i < b; i++)
#define rep4(i, a, b, c) for(ll i = a; i < b; i += c)
#define overload4(a, b, c, d, e, ...) e
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(i, a, b) for (ll i = a; i >= b; i--)
#define fore(i, a) for (auto &i : a)
#define vvl(a,b,c) vector<vector<ll>>(a,vector<ll>(b,c))
#define vvvl(a,b,c,d) vector<vector<vector<ll>>>(a,vvl(b,c,d))
#define enld endl
#define fix(n) cout << fixed << setprecision(n);
#define yesno(b) cout << (b ? "Yes":"No") << endl
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>using rp_queue=priority_queue<T,vector<T>,greater<T>>;
void fast_io(){cin.tie(nullptr);ios_base::sync_with_stdio(false);}
const int inf = INT_MAX / 2;
const ll infl = 1LL<<60;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int dx[8] = {0, 1, 0,-1, 1, 1,-1,-1};
const int dy[8] = {1, 0,-1, 0, 1,-1, 1,-1};

int main() {
    fast_io(); fix(10);
    vector<pair<ld,ld>>ans;
    for(;;) {
        int H,W; cin >> H >> W;
        if(H==0 && W==0) break;
        vector<string>S(H); rep(H) cin >> S[i];
        vector<vector<int>>V(H,vector<int>(W));
        rep(i,H) rep(j,W) V[i][j] = (S[i][j]-'0');

        ld ng = 0, ok = inf;
        for(int _=0; _<100; _++) {
            ld mid = (ok+ng)/2;
            ld dif = 0;
            rep(i,H) rep(j,W) dif += V[i][j]*(i+1-mid);
            if(dif<=0) ok = mid;
            else ng = mid;
        }
        ld r = ok;

        ng = 0, ok = inf;
        for(int _=0; _<100; _++) {
            ld mid = (ok+ng)/2;
            ld dif = 0;
            rep(i,H) rep(j,W) dif += V[i][j]*(j+1-mid);
            if(dif<=0) ok = mid;
            else ng = mid;
        }
        ld c = ok;
        ans.emplace_back(r,c);
    }

    for(auto [r,c] : ans) cout << r << " " << c << endl;
}
accuracy: 1
time_ms: 30
memory_kb: 3508
final_rank: 4

code_snippet: #include <bits/stdc++.h>

#define ll long long
#define rep(i, N) for(ll i = 0; i < (ll)(N); ++i)
#define per(i, N) for(ll i = (ll)(N) - 1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define bit(n, k) (((n) >> (k)) & 1)
#define pcnt(n) (bitset<64>(n).count())
#define fi first
#define se second
#define mkpr make_pair
#define mktpl make_tuple
#define eb emplace_back
template <class T> std::istream& operator>>(std::istream& is, std::vector<T>& V) {
    for (auto& it : V) is >> it;
    return is;
}
template <class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& V) {
    for (int i = 0 ; i < (int)V.size() ; i++) {
        os << V[i] << (i + 1 == (int)V.size() ? "" : " ");
    }
    return os;
}
using namespace std;

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);
    while(true){
        int h,w;
        cin >> h >> w;
        if(h==0 && w==0) return 0;
        vector<string> s(h);
        rep(i,h) cin >> s[i];
        vector<vector<int>> v(h,vector<int>(w));
        rep(i,h) rep(j,w) v[i][j] = s[i][j]-'0';
        double r,c;
        double ok = 10000, ng=0;
        rep(_,60){
            double mid = (ok+ng)/2;
            double val = 0;
            rep(i,h){
                rep(j,w){
                    val += v[i][j]*((i+1)-mid);
                }
            }
            if(val > 0) ng = mid;
            else ok = mid;
        }
        r = ok;
        ok = 10000, ng = 0;
        rep(_,60){
            double mid = (ok+ng)/2;
            double val = 0;
            rep(i,h){
                rep(j,w){
                    val += v[i][j]*((j+1)-mid);
                }
            }
            if(val > 0) ng = mid;
            else ok = mid;
        }
        c = ok;
        cout << setprecision(13) << r << ' ' << c << '\n';
    }
}
accuracy: 1
time_ms: 20
memory_kb: 3528
final_rank: 3

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e9 + 1001010;
const ll llINF = (long long)4e18 + 22000020;
const string endn = "\n";
template <class T> inline auto vector2(size_t i, size_t j, const T &init = T()) {return vector(i, vector<T>(j, init));}
const string ELEM_SEPARATION = " ", VEC_SEPARATION = endn;
template<class T> istream& operator >>(istream &i, vector<T> &A) {for(auto &I : A) {i >> I;} return i;}
template<class T> ostream& operator <<(ostream &o, const vector<T> &A) {int i=A.size(); for(const auto &I : A){o << I << (--i ? ELEM_SEPARATION : "");} return o;}
template<class T> ostream& operator <<(ostream &o, const vector<vector<T>> &A) {int i=A.size(); for(const auto &I : A){o << I << (--i ? VEC_SEPARATION : "");} return o;}
template<class T> vector<T>& operator ++(vector<T> &A, int n) {for(auto &I : A) {I++;} return A;}
template<class T> vector<T>& operator --(vector<T> &A, int n) {for(auto &I : A) {I--;} return A;}
template<class T, class U> bool chmax(T &a, const U &b) {return ((a < b) ? (a = b, true) : false);}
template<class T, class U> bool chmin(T &a, const U &b) {return ((a > b) ? (a = b, true) : false);}
ll floor(ll a, ll b){if (b < 0) a = -a, b = -b; if(a >= 0) return a / b; else return (a + 1) / b - 1;}
ll ceil(ll a, ll b){if (b < 0) a = -a, b = -b; if(a > 0) return (a - 1) / b + 1; else return a / b;}
ll bit(unsigned long long val, unsigned long long digit){return (val >> digit) & 1;}
#ifdef DEBUG
#include <debug_slephy.cpp>
#else
#define debug(...)
#endif
// ================================== ここまでテンプレ ==================================

template<class Judgement>
double binary_search_double(double ok, double ng, Judgement judge, double tolerance, bool considerRelativeError = false){
    auto need_continue = [&]() -> bool {
        if((fabs(ok - ng) < tolerance)) return false; // 絶対誤差
        if(considerRelativeError && (fabs(ok - ng) < tolerance * fabs((ok + ng) * 0.5))) return false; // 相対誤差
        return true;
    };

    while(need_continue()){
        double mid = (ok + ng) * 0.5;
        if(judge(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
};

void solve(){
    ll h, w; cin >> h >> w;
    if(h == 0 && w == 0) exit(0);
    auto tmp = vector<string>(h); cin >> tmp;
    auto v = vector2<ll>(h, w);
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            v[i][j] = (tmp[i][j] - '0');
        }
    }

    debug(v);

    auto judge1 = [&](double r) -> bool {
        double sum = 0;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                sum += v[i][j] * (i+1 - r);
            }
        }
        return sum >= 0.;
    };
    auto judge2 = [&](double c) -> bool {
        double sum = 0;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                sum += v[i][j] * (j+1 - c);
            }
        }
        return sum >= 0.;
    };

    double r = binary_search_double(-1e3, 1e3, judge1, 1e-8, false);
    double c = binary_search_double(-1e3, 1e3, judge2, 1e-8, false);

    cout << setprecision(12) << r << " " << c << endl;
}

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    while(true) solve();
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3768
final_rank: 14

code_snippet: #include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "settings/debug.cpp"
#define _GLIBCXX_DEBUG
#else
#define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main()
{
    while (true)
    {
        int h, w;
        cin >> h >> w;
        if (h + w == 0)
            break;

        vector<string> a(h);
        rep(i, h) cin >> a[i];

        vector v(h, vector<int>(w));
        rep(i, h) rep(j, w) v[i][j] = a[i][j] - '0';

        // 縦の計算
        double left = 0, right = h;
        rep(_, 100)
        {
            double r = (left + right) / 2;
            double torima = 0;
            rep(i, h)
            {
                rep(j, w)
                {
                    torima += v[i][j] * (i + 1 - r);
                }
            } // 計算
            //cerr<<"torima:"<<torima<<endl;
            // torima /= h;
            if (torima > 0)
                left = r;
            else
                right = r; // 更新
        }
        double r = left;
        // 横の計算
        left = 0, right = w;
        rep(_, 100)
        {
            double c = (left + right) / 2;
            double torima = 0;
            rep(i, h)
            {
                rep(j, w)
                {
                    torima += v[i][j] * (j + 1 - c);
                }
            } // 計算
            //cerr<<"torima:"<<torima<<endl;
            if (torima > 0)
                left = c;
            else
                right = c; // 更新
        }
        double c = left;
        cout << fixed << setprecision(15) << r << " " << c << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 3596
final_rank: 11

code_snippet: #include<bits/stdc++.h>
using namespace std;
bool solve()
{
    int H,W;
    cin>>H>>W;
    if(H==0&&W==0)return 0;
    vector<vector<int>>A(H+1,vector<int>(W+1));
    for(int i=1;i<=H;i++)for(int j=1;j<=W;j++)
    {
        char C;
        cin>>C;
        A[i][j]=C-'0';
    }
    double lh=0,rh=H;
    while(rh-lh>1e-8)
    {
        double mh=(lh+rh)/2;
        double sum=0;
        for(int i=1;i<=H;i++)for(int j=1;j<=W;j++)sum+=A[i][j]*(i-mh);
        if(sum<=0)rh=mh;
        else lh=mh;
    }
    double lw=0,rw=W;
    while(rw-lw>1e-8)
    {
        double mw=(lw+rw)/2;
        double sum=0;
        for(int i=1;i<=H;i++)for(int j=1;j<=W;j++)sum+=A[i][j]*(j-mw);
        if(sum<=0)rw=mw;
        else lw=mw;
    }
    cout<<fixed<<setprecision(12)<<rh<<' '<<rw<<'\n';
    return 1;
}
int main()
{
    while(solve()){}
}
accuracy: 1
time_ms: 10
memory_kb: 3472
final_rank: 1

code_snippet: #include<bits/stdc++.h>
using namespace std;

bool solve()
{
  int H,W;
  cin>>H>>W;
  if(H==0&&W==0)return 0;
  vector<vector<int>>A(H+1,vector<int>(W+1));
  for(int i=1;i<=H;i++)for(int j=1;j<=W;j++)
  {
    char c;
    cin>>c;
    A[i][j]=c-'0';
  }
  double lh=0,rh=H;
  while(rh-lh>1e-8)
  {
    double mh=(rh+lh)/2;
    double sum=0;
    for(int i=1;i<=H;i++)for(int j=1;j<=W;j++)sum+=A[i][j]*(i-mh);
    if(sum<=0)rh=mh;
    else lh=mh;
  }
  double lw=0,rw=W;
  while(rw-lw>1e-8)
  {
    double mw=(rw+lw)/2;
    double sum=0;
    for(int i=1;i<=H;i++)for(int j=1;j<=W;j++)sum+=A[i][j]*(j-mw);
    if(sum<=0)rw=mw;
    else lw=mw;
  }
  cout<<fixed<<setprecision(16)<<rh<<' '<<rw<<"\n";
  return 1;
}
int main(){
  while(solve()){}
}
accuracy: 1
time_ms: 10
memory_kb: 3576
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
  #define _GLIBCXX_DEBUG
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  while (true) {
    int h, w;
    cin >> h >> w;
    if (h + w == 0) break;
    vector Grid(h, vector<char>(w));
    rep(i, h) rep(j, w) cin >> Grid[i][j];
    double hor_l = 0, hor_r = w, ver_l = 0, ver_r = h;
    rep(_, 100) {
      double hor_mid = (hor_l + hor_r) / 2;
      double sum = 0;
      rep(i, h) rep(j, w) {
        sum += (Grid[i][j] - '0') * (j + 1 - hor_mid);
      }
      (sum > 0 ? hor_l : hor_r) = hor_mid;
    }
    rep(_, 100) {
      double ver_mid = (ver_l + ver_r) / 2;
      double sum = 0;
      rep(i, h) rep(j, w) {
        sum += (Grid[i][j] - '0') * (i + 1 - ver_mid);
      }
      (sum > 0 ? ver_l : ver_r) = ver_mid;
    }
    cout << fixed << setprecision(15) << ver_l << " " << hor_l << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 3464
final_rank: 2

code_snippet: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;
using namespace std;

void solve(int H, int W) {
    vector V(H, vector<int>(W));
    rep(i, H) {
        string S;
        cin >> S;
        rep(j, W) V[i][j] = S[j] - '0';
    }

    {
        auto check = [&](double x) -> bool {
            double sum = 0;
            rep(i, H) rep(j, W) {
                sum += V[i][j] * ((i + 1) - x);
            }

            return sum >= 0;
        };
        auto check2 = [&](double x) -> bool {
            double sum = 0;
            rep(i, H) rep(j, W) {
                sum += V[i][j] * ((j + 1) - x);
            }

            return sum >= 0;
        };

        double ok = 0, ng = H + 1;
        rep(i, 300) {
            double mid = (ok + ng) / 2;
            if (check(mid))
                ok = mid;
            else
                ng = mid;
        }
        printf("%.10f ", ok);

        ok = 0, ng = W + 1;
        rep(i, 300) {
            double mid = (ok + ng) / 2;
            if (check2(mid))
                ok = mid;
            else
                ng = mid;
        }
        printf("%.10f\n", ok);
    }
}

int main() {
    cin.tie(0)->sync_with_stdio(0);

    int H, W;
    while (cin >> H >> W, H) solve(H, W);

    return 0;
}
accuracy: 1
time_ms: 110
memory_kb: 3604
final_rank: 15

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1e18
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
typedef pair<int, int> P;
typedef pair<int, P> PP;
//const int mod = 1000000007;
const int mod = 998244353;

int h, w;
double v[110][110];

signed main(){
    cout << fixed << setprecision(18);

    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0)break;
        rep(i, h){
            string s;
            cin >> s;
            rep(j, w)v[i][j] = s[j] - '0';
        }
        double left = 0.0, right = 100.0;
        rep(I, 100){
            double mid = (left + right) / 2;
            double sum = 0;
            rep(i, h)rep(j, w)sum += (double)v[i][j] * (i - mid);
            if(sum <= 0)right = mid;
            else left = mid;
        }
        double r = right + 1.0;
        left = 0.0, right = 100.0;
        rep(I, 100){
            double mid = (left + right) / 2;
            double sum = 0;
            rep(i, h)rep(j, w)sum += (double)v[i][j] * (j - mid);
            if(sum <= 0)right = mid;
            else left = mid;
        }
        double c = right + 1.0;
        cout << r << " " << c << endl;
    }
}
accuracy: 1
time_ms: 40
memory_kb: 3552
final_rank: 9

code_snippet: #include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1000000007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

int H, W;

bool checkr(vector<vector<int>> &v, double r){
	double res = 0;
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			res += v[i][j] * (i+1 - r);
		}
	}
	
	return res > 0;
}

bool checkc(vector<vector<int>> &v, double c){
	double res = 0;
	
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			res += v[i][j] * (j+1 - c);
		}
	}
	
	return res > 0;
}

bool solve(){
	double a, b;
	vector<vector<int>> v;
	
	cin>>H>>W;
	
	if(!H) return false;
	
	v.resize(H, vector<int>(W));
	
	for(int i = 0; i < H; i++){
		string S;
		cin>>S;
		
		for(int j = 0; j < W; j++){
			v[i][j] = S[j]-'0';
		}
	}
	
	{
		double l = 0, r = H, m;
		
		for(int i = 0; i < 100; i++){
			m = (l + r) / 2;
			
			if(checkr(v, m)) {
				l = m;
			} else {
				r = m;
			}
		}
		
		a = r;
	}
	
	{
		double l = 0, r = W, m;
		
		for(int i = 0; i < 100; i++){
			m = (l + r) / 2;
			
			if(checkc(v, m)) {
				l = m;
			} else {
				r = m;
			}
		}
		
		b = r;
	}
	
	cout<<a<<" "<<b<<endl;
	
	return true;
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	while(solve());
	
	return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3672
final_rank: 13

code_snippet: #include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
    for(T &in : v) is >> in;
    return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
    for(int i = 0; i < (int) v.size(); i++) {
        os << v[i] << (i + 1 != (int) v.size() ? " " : "");
    }
    return os;
}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int h,w;
    while(cin>>h>>w, h){
        vector<string> s(h);
        cin>>s;
        int cnt = 111;
        vector<double> ans;
        double low=0,up=h+1,mid;
        while(cnt--){
            mid=(up+low)/2;
            double ret = 0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    ret += (i - mid) * (s[i][j] - '0');
                }
            }
            if(ret >= 0){
                low=mid;
            }
            else{
                up=mid;
            }
        }
        ans.push_back(low + 1);
        low = 0, up = w + 1, cnt = 111;
        while(cnt--){
            mid=(up+low)/2;
            double ret = 0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    ret += (j - mid) * (s[i][j] - '0');
                }
            }
            if(ret >= 0){
                low=mid;
            }
            else{
                up=mid;
            }
        }
        ans.push_back(low + 1);
        cout << ans << endl;
    }
}
accuracy: 1
time_ms: 40
memory_kb: 3512
final_rank: 7

code_snippet: #include <bits/stdc++.h>
using namespace std;

template<typename F>
pair<double,double> Binary(double ok, double ng, const F &isok, int m = 200){
  for(int t = 0; t < m; t++){
    double wj = ((ok - ng)/2) + ng;
    (isok(wj)?ok : ng) = wj;
  }
  return {ok, ng};
}


int main() {
  while(true){
    int h, w; cin >> h >> w;
    if(h == 0) return 0;

    vector v(h, vector(w, 0));
    for(int i = 0; i < h; ++i){
      string s; cin >> s;
      for(int j = 0; j < w; ++j) v[i][j] = s[j] - '0';
    }

    auto[d,u] = Binary(0, h, [&](double r){ 
      double sum = 0;
      for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
          sum += v[i][j] * (i + 1 - r);
        }
      }
      return sum >= 0;
    });

    auto[l,r] = Binary(0, w, [&](double c){ 
      double sum = 0;
      for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
          sum += v[i][j] * (j + 1 - c);
        }
      }
      return sum >= 0;
    });

    cout << fixed << setprecision(12);
    cout << d << " " << l << "\n";
  }
}
accuracy: 1
time_ms: 70
memory_kb: 3568
final_rank: 12