結果
| 問題 | No.5021 Addition Pyramid | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-09-13 12:16:50 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 472 ms / 2,000 ms | 
| コード長 | 1,383 bytes | 
| コンパイル時間 | 890 ms | 
| コンパイル使用メモリ | 90,560 KB | 
| 実行使用メモリ | 7,716 KB | 
| スコア | 8,593,299 | 
| 最終ジャッジ日時 | 2025-09-13 12:17:17 | 
| 合計ジャッジ時間 | 26,651 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
| 純コード判定しない問題か言語 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 50 | 
ソースコード
#include <iostream>
#include <algorithm>
#include <ctime>
#include <cmath>
using namespace std;
int n;
const int mod = 100000000;
long long goal[55][55];
long long ans[55][55];
long long get_score() {
	for (int i = n - 1; i >= 1; i--) {
		for (int j = 1; j <= i; j++) {
			ans[i][j] = (ans[i + 1][j] + ans[i + 1][j + 1]) % mod;
		}
	}
	
	long long X = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= i; j++) {
			long long d = min(abs(goal[i][j] - ans[i][j]), abs(mod - abs(goal[i][j] - ans[i][j])));
			X = max(X, d);
		}
	}
	
	long long score = 50000000 - X;
	return score;
}
void solve() {
	srand((unsigned)time(NULL));
	for (int i = 1; i <= n; i++) ans[n][i] = goal[n][i];
	long long now_score = get_score();
	
	for (int i = 1; i <= 100000; i++) {
		int a = rand() % n + 1, b = rand() % 100 - 50;
		int befo = ans[n][a];
		ans[n][a] += b;
		ans[n][a] %= mod;
		if (ans[n][a] < 0) ans[n][a] += mod;
		
		long long new_score = get_score();
		
		double Randouble = 1.0 * rand() / RAND_MAX;
		double T = 20.0 - 19.0 * i / 100000.0;
		double Probability = exp(min(0.0, (new_score - now_score) / T));
		if (Probability > Randouble) now_score = new_score;
		else ans[n][a] = befo;
	}
	
}
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++) for (int j = 1; j <= i; j++) cin >> goal[i][j];
	
	solve();
	
	for (int i = 1; i <= n; i++) cout << ans[n][i] << " ";
	return 0;
}
            
            
            
        