結果
| 問題 |
No.2320 Game World for PvP
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-28 20:24:00 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,145 bytes |
| コンパイル時間 | 6,912 ms |
| コンパイル使用メモリ | 259,664 KB |
| 最終ジャッジ日時 | 2025-02-13 15:52:05 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | AC * 1 RE * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std ;
random_device rd;
mt19937 eng(rd());
uniform_real_distribution<> prr;
int main () {
clock_t st = clock();
int N, s, t;
scanf(" %d %d %d", &N, &s, &t);
std::vector<int> id(N, -1);
for (int i = 0; i < s; i ++) {
int a;
scanf(" %d", &a);
id[--a] = 0;
}
for (int i = 0; i < t; i ++) {
int a;
scanf(" %d", &a);
id[--a] = 1;
}
for (auto& a : id) {
if (a == -1) {
double x = prr(eng);
a = (x < 0.5);
}
}
using ll = long long;
ll C[66][66];
ll sum = 0;
for (int i = 0; i < N; i ++) {
for (int j = 0; j < N; j ++) {
scanf(" %lld", &C[i][j]);
if (i <= j) sum += C[i][j];
}
}
ll now = 0;
for (int i = 0; i < N; i ++) {
for (int j = i; j < N; j ++) {
if (id[i] != id[j]) {
now += C[i][j];
}
}
}
ll ans = now;
while ((double)(clock() - st) / CLOCKS_PER_SEC < 1.9) {
int u = prr(eng) * N;
ll pl = 0;
for (int i = 0; i < N; i ++) {
u += C[i][u] * (id[u] == id[i] ? 1 : -1);
}
double x = (pl > 0 ? 2 : exp(10.0 * pl / sum));
if (prr(eng) < x) {
now += pl;
id[u] ^= 1;
}
ans = min(ans, now);
}
cout << sum - ans << endl;
}