From d47e8579413a3197267b66467497364e217f5520 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 27 Aug 2022 13:18:15 +0800 Subject: [PATCH] =?UTF-8?q?#1494.=20=E5=AF=BC=E5=BC=B9=E6=8B=A6=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://sjzezoj.com/submission/55732 --- S2OJ/1494/1494.cpp | 134 ++++++++++++++++++++++++++++++++++++ S2OJ/1494/data/data1.in | 3 + S2OJ/1494/data/data1.out | 3 + S2OJ/1494/data/data10.in | 3 + S2OJ/1494/data/data10.out | 3 + S2OJ/1494/data/data2.in | 3 + S2OJ/1494/data/data2.out | 3 + S2OJ/1494/data/data3.in | 3 + S2OJ/1494/data/data3.out | 3 + S2OJ/1494/data/data4.in | 3 + S2OJ/1494/data/data4.out | 3 + S2OJ/1494/data/data5.in | 3 + S2OJ/1494/data/data5.out | 3 + S2OJ/1494/data/data6.in | 3 + S2OJ/1494/data/data6.out | 3 + S2OJ/1494/data/data7.in | 3 + S2OJ/1494/data/data7.out | 3 + S2OJ/1494/data/data8.in | 3 + S2OJ/1494/data/data8.out | 3 + S2OJ/1494/data/data9.in | 3 + S2OJ/1494/data/data9.out | 3 + S2OJ/1494/data/problem.conf | 3 + 22 files changed, 197 insertions(+) create mode 100644 S2OJ/1494/1494.cpp create mode 100644 S2OJ/1494/data/data1.in create mode 100644 S2OJ/1494/data/data1.out create mode 100644 S2OJ/1494/data/data10.in create mode 100644 S2OJ/1494/data/data10.out create mode 100644 S2OJ/1494/data/data2.in create mode 100644 S2OJ/1494/data/data2.out create mode 100644 S2OJ/1494/data/data3.in create mode 100644 S2OJ/1494/data/data3.out create mode 100644 S2OJ/1494/data/data4.in create mode 100644 S2OJ/1494/data/data4.out create mode 100644 S2OJ/1494/data/data5.in create mode 100644 S2OJ/1494/data/data5.out create mode 100644 S2OJ/1494/data/data6.in create mode 100644 S2OJ/1494/data/data6.out create mode 100644 S2OJ/1494/data/data7.in create mode 100644 S2OJ/1494/data/data7.out create mode 100644 S2OJ/1494/data/data8.in create mode 100644 S2OJ/1494/data/data8.out create mode 100644 S2OJ/1494/data/data9.in create mode 100644 S2OJ/1494/data/data9.out create mode 100644 S2OJ/1494/data/problem.conf diff --git a/S2OJ/1494/1494.cpp b/S2OJ/1494/1494.cpp new file mode 100644 index 00000000..8a6663c0 --- /dev/null +++ b/S2OJ/1494/1494.cpp @@ -0,0 +1,134 @@ +#include +#include +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 1e6 + 5; + +int n, s, t, f[N], ans; +std::tuple points[N]; +int idx, head[N << 1], ver[N << 2], edge[N << 2], next[N << 2]; +int cur[N << 1], dist[N << 1]; + +void add(int u, int v, int w) { + next[idx] = head[u]; + ver[idx] = v; + edge[idx] = w; + head[u] = idx++; +} + +bool bfs() { + std::fill_n(dist, N << 1, 0); + + std::queue q; + + q.push(s); + dist[s] = 1; + 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 (dist[v] == dist[u] + 1 && w) { + int k = dinic(v, std::min(w, limit - flow)); + + if (!k) { + dist[v] = 0; + } else { + flow += k; + edge[i] -= k; + edge[i ^ 1] += k; + } + } + } + + return flow; +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + std::fill_n(head, N << 1, -1); + + cin >> n; + + for (int i = 1; i <= n; i++) { + cin >> std::get<0>(points[i]) >> std::get<1>(points[i]) >> std::get<2>(points[i]); + } + + std::sort(points + 1, points + 1 + n); + + for (int i = 1; i <= n; i++) { + f[i] = 1; + + for (int j = 1; j < i; j++) { + int x1, y1, z1, + x2, y2, z2; + + std::tie(x1, y1, z1) = points[i]; + std::tie(x2, y2, z2) = points[j]; + + if (x2 < x1 && y2 < y1 && z2 < z1) { + f[i] = std::max(f[i], f[j] + 1); + + add(j, i + n, 1); + add(i + n, j, 0); + } + } + + ans = std::max(ans, f[i]); + } + + s = n * 2 + 1, t = s + 1; + for (int i = 1; i <= n; i++) { + add(s, i, 1); + add(i, s, 0); + + add(i + n, t, 1); + add(t, i + n, 0); + } + + int res = 0, flow; + while (bfs()) { + while (flow = dinic(s, std::numeric_limits::max())) res += flow; + } + + cout << ans << endl + << n - res << endl; + + return 0; +} diff --git a/S2OJ/1494/data/data1.in b/S2OJ/1494/data/data1.in new file mode 100644 index 00000000..5e3cfe1f --- /dev/null +++ b/S2OJ/1494/data/data1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe2b0419d46bccf6f9c438f9b92e5c81536ac8545f3e1a593f5ff8e0c81acdbd +size 208 diff --git a/S2OJ/1494/data/data1.out b/S2OJ/1494/data/data1.out new file mode 100644 index 00000000..44046801 --- /dev/null +++ b/S2OJ/1494/data/data1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:56c47cb32092661c2f3438298862e0759fa78694dbe78060f6369502f4386a09 +size 4 diff --git a/S2OJ/1494/data/data10.in b/S2OJ/1494/data/data10.in new file mode 100644 index 00000000..00fddd00 --- /dev/null +++ b/S2OJ/1494/data/data10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:50e07613c0a078c6aabb7fc3ba14bcfb7d52b47f6e6af650340706f6bbc435bb +size 19937 diff --git a/S2OJ/1494/data/data10.out b/S2OJ/1494/data/data10.out new file mode 100644 index 00000000..18b84657 --- /dev/null +++ b/S2OJ/1494/data/data10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c76e4d6e93b45d654e2aa7a827149fc91bee8a584c4222145b8b3f519ec53eeb +size 7 diff --git a/S2OJ/1494/data/data2.in b/S2OJ/1494/data/data2.in new file mode 100644 index 00000000..0f4823ab --- /dev/null +++ b/S2OJ/1494/data/data2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8338593ba3c4dadbeb3ce70257b77d651e97753544b2caf86c9cdfa0a6acabb1 +size 18248 diff --git a/S2OJ/1494/data/data2.out b/S2OJ/1494/data/data2.out new file mode 100644 index 00000000..48765f26 --- /dev/null +++ b/S2OJ/1494/data/data2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22a46f572bd2fad2608ddb060565fd0c5c90b7400d4383b08a1403b6281e74bf +size 7 diff --git a/S2OJ/1494/data/data3.in b/S2OJ/1494/data/data3.in new file mode 100644 index 00000000..ee91e9a1 --- /dev/null +++ b/S2OJ/1494/data/data3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:40a6969a6ef67949389828f1915f50237f73f53ff5b0bc6a4a828444cd5ffdc2 +size 19753 diff --git a/S2OJ/1494/data/data3.out b/S2OJ/1494/data/data3.out new file mode 100644 index 00000000..253da7ce --- /dev/null +++ b/S2OJ/1494/data/data3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:036633bfa4e561f2a33b147565450ae16e2293b14f65615b2ea0200eb8dbdded +size 7 diff --git a/S2OJ/1494/data/data4.in b/S2OJ/1494/data/data4.in new file mode 100644 index 00000000..e7d4a0ab --- /dev/null +++ b/S2OJ/1494/data/data4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e902350969875ffa4078ce21f1e183c2c956152e9c3d4860e78a5aa4aeac92fb +size 214 diff --git a/S2OJ/1494/data/data4.out b/S2OJ/1494/data/data4.out new file mode 100644 index 00000000..ac612450 --- /dev/null +++ b/S2OJ/1494/data/data4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b3afef0e7bc7a4e8a30048b5388d63af1c62c2932c7bd15c9db71695e6b9ebc3 +size 4 diff --git a/S2OJ/1494/data/data5.in b/S2OJ/1494/data/data5.in new file mode 100644 index 00000000..27e2eb1d --- /dev/null +++ b/S2OJ/1494/data/data5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c2c178838f482a84bd6c919208e733b762dd6919ac69e93e5044ebb41519ec2c +size 213 diff --git a/S2OJ/1494/data/data5.out b/S2OJ/1494/data/data5.out new file mode 100644 index 00000000..44046801 --- /dev/null +++ b/S2OJ/1494/data/data5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:56c47cb32092661c2f3438298862e0759fa78694dbe78060f6369502f4386a09 +size 4 diff --git a/S2OJ/1494/data/data6.in b/S2OJ/1494/data/data6.in new file mode 100644 index 00000000..4c882160 --- /dev/null +++ b/S2OJ/1494/data/data6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:712dcde0fb9e38733e1683d5863d42681e4e98cb962f7ad0019eaacef63efba9 +size 20550 diff --git a/S2OJ/1494/data/data6.out b/S2OJ/1494/data/data6.out new file mode 100644 index 00000000..9fa060be --- /dev/null +++ b/S2OJ/1494/data/data6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8d41bc02930cc1f63e1ca5e2d4714727374cb4d77b9481122686b1c7931d2d48 +size 7 diff --git a/S2OJ/1494/data/data7.in b/S2OJ/1494/data/data7.in new file mode 100644 index 00000000..cd260825 --- /dev/null +++ b/S2OJ/1494/data/data7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a5bda5bb4b1c51c87f102170ea72eb9e457a7597b6d729e0d4fb2819b3bbf2c0 +size 20130 diff --git a/S2OJ/1494/data/data7.out b/S2OJ/1494/data/data7.out new file mode 100644 index 00000000..39b6f3da --- /dev/null +++ b/S2OJ/1494/data/data7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7195c407dd48a53f3a55c52d13275f23915a1f00622e596f529e2ae6ef412bd1 +size 7 diff --git a/S2OJ/1494/data/data8.in b/S2OJ/1494/data/data8.in new file mode 100644 index 00000000..bd41d41f --- /dev/null +++ b/S2OJ/1494/data/data8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae297375305490aaaa866ff9f66c9c89660d386efa0892e812d5e98b713804a3 +size 19073 diff --git a/S2OJ/1494/data/data8.out b/S2OJ/1494/data/data8.out new file mode 100644 index 00000000..38e5dbe0 --- /dev/null +++ b/S2OJ/1494/data/data8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:690262e45884fb439970a6b652d2fbf00e5b1a7b5c27bf0113c2d9cac96467e2 +size 7 diff --git a/S2OJ/1494/data/data9.in b/S2OJ/1494/data/data9.in new file mode 100644 index 00000000..8b3adc89 --- /dev/null +++ b/S2OJ/1494/data/data9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:db9ad8db7b30852a7f3198887b73f43c94fe648bbbaaf8b706bccae159eaf7c5 +size 16882 diff --git a/S2OJ/1494/data/data9.out b/S2OJ/1494/data/data9.out new file mode 100644 index 00000000..1ecca97e --- /dev/null +++ b/S2OJ/1494/data/data9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ac6133ecb9b90f17463ca3793883062fa167b2ec0af5070a2266617e50134d55 +size 7 diff --git a/S2OJ/1494/data/problem.conf b/S2OJ/1494/data/problem.conf new file mode 100644 index 00000000..4123f747 --- /dev/null +++ b/S2OJ/1494/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ea854f4e7fc39bb22aeb2188ace2efdd3dee3e986edbcd7e2d0d7404b9941574 +size 177