0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 03:31:59 +00:00

1391. [Ceoi2008]order

https://hydro.ac/d/bzoj/record/6322c9dabdf9bc31d1607e4d
This commit is contained in:
Baoshuo Ren 2022-09-15 14:44:58 +08:00
parent b1f483a26d
commit 3256f5c172
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
37 changed files with 234 additions and 0 deletions

126
BZOJ/1391/1391.cpp Normal file
View File

@ -0,0 +1,126 @@
#pragma GCC optimize("Ofast")
#include <iostream>
#include <cstring>
#include <limits>
#include <queue>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 2e6 + 5;
int n, m, s, t, sum;
int idx, head[N], edge[N << 1], ver[N << 1], next[N << 1];
int dist[N], cur[N];
void add(int u, int v, int w) {
next[idx] = head[u];
ver[idx] = v;
edge[idx] = w;
head[u] = idx++;
}
bool bfs() {
memset(dist, 0x00, sizeof(dist));
std::queue<int> q;
dist[s] = 1;
q.push(s);
cur[s] = head[s];
while (!q.empty()) {
int u = q.front();
q.pop();
for (int i = head[u]; ~i; i = next[i]) {
int v = ver[i],
w = edge[i];
if (w && !dist[v]) {
dist[v] = dist[u] + 1;
cur[v] = head[v];
if (v == t) return true;
q.push(v);
}
}
}
return false;
}
int dinic(int u, int limit) {
if (u == t) return limit;
int flow = 0;
for (int i = cur[u]; ~i && flow < limit; i = next[i]) {
cur[u] = i;
int v = ver[i],
w = edge[i];
if (w && dist[v] == dist[u] + 1) {
int k = dinic(v, std::min(limit - flow, w));
if (!k) dist[v] = 0;
edge[i] -= k;
edge[i ^ 1] += k;
flow += k;
}
}
return flow;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
memset(head, 0xff, sizeof(head));
cin >> n >> m;
s = 0, t = n + m + 1;
for (int i = 1; i <= n; i++) {
int x, t;
cin >> x >> t;
add(s, i, x);
add(i, s, 0);
sum += x;
for (int j = 1; j <= t; j++) {
int a, b;
cin >> a >> b;
add(i, a + n, b);
add(a + n, i, 0);
}
}
for (int i = 1; i <= m; i++) {
int y;
cin >> y;
add(i + n, t, y);
add(t, i + n, 0);
}
int res = 0, flow;
while (bfs()) {
while (flow = dinic(s, std::numeric_limits<int>::max())) res += flow;
}
cout << sum - res << endl;
return 0;
}

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.