結果
| 問題 |
No.5021 Addition Pyramid
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-13 12:27:32 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,393 bytes |
| コンパイル時間 | 859 ms |
| コンパイル使用メモリ | 90,544 KB |
| 実行使用メモリ | 7,720 KB |
| スコア | 30,507,793 |
| 最終ジャッジ日時 | 2025-09-13 12:29:19 |
| 合計ジャッジ時間 | 105,274 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 TLE * 20 |
ソースコード
#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 <= 450000; i++) {
int a = rand() % n + 1, b = rand() % 10000000 - 5000000;
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 = 60.0 - 59.0 * i / 450000.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;
}