0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-13 09:58:47 +00:00

3232. 圈地游戏

https://hydro.ac/d/bzoj/record/63b7bef8eae63550a15bee05
This commit is contained in:
Baoshuo Ren 2023-01-06 14:26:42 +08:00
parent 1dfb3067fc
commit 0dd2f8f42b
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
21 changed files with 172 additions and 0 deletions

112
BZOJ/3232/3232.cpp Normal file
View File

@ -0,0 +1,112 @@
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <iterator>
#include <queue>
#include <tuple>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 55;
const double eps = 1e-6;
int n, m, s[N][N];
std::vector<std::tuple<int, int, int>> g[N * N];
int cnt[N * N];
double dist[N * N];
bool vis[N * N];
int id(int x, int y) {
return (x - 1) * (m + 1) + y;
}
bool check(double x) {
std::fill(std::begin(cnt), std::end(cnt), 0);
std::fill(std::begin(dist), std::end(dist), -1e9);
std::fill(std::begin(vis), std::end(vis), false);
std::queue<int> q;
q.emplace(1);
dist[1] = 0;
vis[1] = true;
while (!q.empty()) {
int u = q.front();
q.pop();
vis[u] = false;
for (auto e : g[u]) {
int v, a, b;
std::tie(v, a, b) = e;
double w = static_cast<double>(b) - x * a;
if (dist[v] < dist[u] + w) {
dist[v] = dist[u] + w;
if (!vis[v]) {
cnt[v] = cnt[u] + 1;
if (cnt[v] > (n + 1) * (m + 1)) return false;
vis[v] = true;
q.emplace(v);
}
}
}
}
return true;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1, x; j <= m; j++) {
cin >> x;
s[i][j] = s[i][j - 1] + x;
}
}
for (int i = 1; i <= n + 1; i++) {
for (int j = 1, x; j <= m; j++) {
cin >> x;
g[id(i, j)].emplace_back(id(i, j + 1), x, 0);
g[id(i, j + 1)].emplace_back(id(i, j), x, 0);
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1, x; j <= m + 1; j++) {
cin >> x;
g[id(i, j)].emplace_back(id(i + 1, j), x, -s[i][j - 1]);
g[id(i + 1, j)].emplace_back(id(i, j), x, s[i][j - 1]);
}
}
double l = 0, r = 1000;
while (r - l > eps) {
double mid = (l + r) / 2;
if (check(mid)) r = mid;
else l = mid;
}
cout << std::fixed << std::setprecision(3) << l << endl;
return 0;
}

BIN
BZOJ/3232/data/1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3232/data/9.out (Stored with Git LFS) Normal file

Binary file not shown.