0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-16 19:45:24 +00:00

4720. [Noip2016] 换教室

https://hydro.ac/d/bzoj/record/63a45c2bb053be17396a03b2
This commit is contained in:
Baoshuo Ren 2022-12-22 21:31:31 +08:00
parent 955281f7cb
commit c361a8e1c2
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
101 changed files with 392 additions and 0 deletions

92
BZOJ/4720/4720.cpp Normal file
View File

@ -0,0 +1,92 @@
#include <iostream>
#include <algorithm>
#include <cstring>
#include <iomanip>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 2005,
V = 305;
int n, m, v, e, c[N], d[N], g[V][V];
double p[N], f[N][N][2], ans = 1e9;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m >> v >> e;
memset(g, 0x3f, sizeof(g));
for (int i = 1; i <= n; i++) {
cin >> c[i];
}
for (int i = 1; i <= n; i++) {
cin >> d[i];
}
for (int i = 1; i <= n; i++) {
cin >> p[i];
}
for (int i = 1; i <= v; i++) {
g[i][i] = 0;
}
for (int i = 1, a, b, w; i <= e; i++) {
cin >> a >> b >> w;
g[a][b] = g[b][a] = std::min(g[a][b], w);
}
for (int k = 1; k <= v; k++) {
for (int i = 1; i <= v; i++) {
for (int j = 1; j <= v; j++) {
g[i][j] = std::min(g[i][j], g[i][k] + g[k][j]);
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= m; j++) {
f[i][j][0] = f[i][j][1] = 1e9;
}
}
f[1][0][0] = f[1][1][1] = 0;
for (int i = 2; i <= n; i++) {
for (int j = 0; j <= std::min(m, i); j++) {
f[i][j][0] = std::min(
f[i - 1][j][0]
+ g[c[i - 1]][c[i]],
f[i - 1][j][1]
+ p[i - 1] * g[d[i - 1]][c[i]]
+ (1.0 - p[i - 1]) * g[c[i - 1]][c[i]]);
if (j) {
f[i][j][1] = std::min(
f[i - 1][j - 1][0]
+ p[i] * g[c[i - 1]][d[i]]
+ (1.0 - p[i]) * g[c[i - 1]][c[i]],
f[i - 1][j - 1][1]
+ p[i - 1] * p[i] * g[d[i - 1]][d[i]]
+ (1.0 - p[i - 1]) * p[i] * g[c[i - 1]][d[i]]
+ p[i - 1] * (1.0 - p[i]) * g[d[i - 1]][c[i]]
+ (1.0 - p[i - 1]) * (1.0 - p[i]) * g[c[i - 1]][c[i]]);
}
}
}
for (int i = 0; i <= m; i++) {
ans = std::min({ans, f[n][i][0], f[n][i][1]});
}
cout << std::fixed << std::setprecision(2) << ans << endl;
return 0;
}

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

BIN
BZOJ/4720/data/11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/16.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/17.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/18.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/19.out (Stored with Git LFS) Normal file

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

BIN
BZOJ/4720/data/20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/20.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/21.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/21.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/22.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/22.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/23.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/23.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/24.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/24.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/25.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/25.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/26.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/26.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/27.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/27.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/28.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/28.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/29.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/29.out (Stored with Git LFS) Normal file

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

BIN
BZOJ/4720/data/30.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/30.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/31.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/31.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/32.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/32.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/33.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/33.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/34.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/34.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/35.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/35.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/36.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/36.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/37.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/37.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/38.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/38.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/39.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/39.out (Stored with Git LFS) Normal file

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

BIN
BZOJ/4720/data/40.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/40.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/41.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/41.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/42.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/42.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/43.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/43.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/44.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/44.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/45.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/45.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/46.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/46.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/47.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/47.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/48.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/48.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/49.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/49.out (Stored with Git LFS) Normal file

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

BIN
BZOJ/4720/data/50.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/4720/data/50.out (Stored with Git LFS) Normal file

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More