#include using namespace std; static const int N = 50; static const int MOD = 100000000; typedef long long ll; struct SAParams { double T0 = 1e4; double Tend = 1e-4; double alpha = 0.99995; double timeLimit = 1.9; int deltaRange = 1000000; }; struct PyramidSolver { int a[N][N], b[N][N]; int cur[N], best[N]; int bestScore; SAParams params; mt19937_64 rng; uniform_int_distribution uni_pos; uniform_int_distribution uni_delta; uniform_real_distribution uni_real; PyramidSolver() : rng(chrono::high_resolution_clock::now().time_since_epoch().count()), uni_pos(0, N - 1), uni_delta(-params.deltaRange, params.deltaRange), uni_real(0.0, 1.0) {} void readInput() { for (int i = 0; i < N; i++) for (int j = 0; j <= i; j++) cin >> a[i][j]; } void build() { for (int j = 0; j < N; j++) b[N - 1][j] = (cur[j] % MOD + MOD) % MOD; for (int i = N - 2; i >= 0; i--) for (int j = 0; j <= i; j++) b[i][j] = (b[i + 1][j] + b[i + 1][j + 1]) % MOD; } int evaluate() { int mx = 0; for (int i = 0; i < N; i++) for (int j = 0; j <= i; j++) { int diff = abs(a[i][j] - b[i][j]); mx = max(mx, min(diff, MOD - diff)); } return mx; } void anneal() { auto start = chrono::high_resolution_clock::now(); for (int i = 0; i < N; i++) cur[i] = uniform_int_distribution(0, MOD - 1)(rng); build(); int curScore = evaluate(); memcpy(best, cur, sizeof(cur)); bestScore = curScore; double T = params.T0; while (true) { auto now = chrono::high_resolution_clock::now(); if (chrono::duration(now - start).count() >= params.timeLimit || T <= params.Tend) break; int pos = uni_pos(rng); int old = cur[pos]; cur[pos] = (old + uni_delta(rng) + MOD) % MOD; build(); int newScore = evaluate(); int diff = newScore - curScore; if (diff < 0 || exp(-diff / T) > uni_real(rng)) { curScore = newScore; if (newScore < bestScore) { bestScore = newScore; memcpy(best, cur, sizeof(cur)); } } else { cur[pos] = old; } T *= params.alpha; } } void output() const { for (int i = 0; i < N; i++) cout << best[i] << (i + 1 < N ? ' ' : '\n'); cerr << "Max Error: " << bestScore << '\n'; cerr << "Score: " << (50000000 - bestScore) << '\n'; } void solve() { readInput(); anneal(); output(); } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); PyramidSolver solver; solver.solve(); return 0; }