mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
P7687 [CEOI2005] Critical Network Lines
https://www.luogu.com.cn/record/102265524
This commit is contained in:
parent
becee5f04e
commit
ba2d1e93ad
76
Luogu/P7687/P7687.cpp
Normal file
76
Luogu/P7687/P7687.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 1e5 + 5;
|
||||
|
||||
int n, m, k, l, a[N], b[N];
|
||||
std::vector<int> g[N];
|
||||
int dfn[N], low[N];
|
||||
bool bridge[N];
|
||||
std::vector<std::pair<int, int>> ans;
|
||||
|
||||
void tarjan(int u, int f) {
|
||||
static int cnt = 0;
|
||||
|
||||
dfn[u] = low[u] = ++cnt;
|
||||
|
||||
for (int v : g[u]) {
|
||||
if (!dfn[v]) {
|
||||
tarjan(v, u);
|
||||
|
||||
low[u] = std::min(low[u], low[v]);
|
||||
|
||||
if (dfn[u] < low[v]) {
|
||||
if (a[v] == 0 || b[v] == 0 || a[v] == k || b[v] == l) {
|
||||
ans.emplace_back(u, v);
|
||||
}
|
||||
}
|
||||
|
||||
a[u] += a[v];
|
||||
b[u] += b[v];
|
||||
} else if (v != f) {
|
||||
low[u] = std::min(low[u], dfn[v]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
cin >> n >> m >> k >> l;
|
||||
|
||||
for (int i = 1, x; i <= k; i++) {
|
||||
cin >> x;
|
||||
|
||||
a[x] = 1;
|
||||
}
|
||||
|
||||
for (int i = 1, x; i <= l; i++) {
|
||||
cin >> x;
|
||||
|
||||
b[x] = 1;
|
||||
}
|
||||
|
||||
for (int i = 1, u, v; i <= m; i++) {
|
||||
cin >> u >> v;
|
||||
|
||||
g[u].push_back(v);
|
||||
g[v].push_back(u);
|
||||
}
|
||||
|
||||
tarjan(1, 1);
|
||||
|
||||
cout << ans.size() << endl;
|
||||
|
||||
for (auto e : ans) {
|
||||
cout << e.first << ' ' << e.second << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
BIN
Luogu/P7687/data/checker.cpp
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/checker.cpp
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net0xxl.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net0xxl.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net0xxl.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net0xxl.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net1.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net1.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net11.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net11.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net13.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net13.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net13.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net13.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net15.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net15.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net15.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net15.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net17.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net17.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net17.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net17.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net19.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net19.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net19.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net19.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net21.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net21.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net21.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net21.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net23.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net23.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net23.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net23.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net25.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net25.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net25.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net25.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net27.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net27.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net27.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net27.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net29.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net29.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net29.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net29.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net3.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net3.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net31.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net31.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net31.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net31.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net33.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net33.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net33.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net33.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net35.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net35.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net35.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net35.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net37.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net37.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net37.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net37.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net39.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net39.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net39.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net39.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net5.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net5.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net7.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net7.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net9.in
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
Luogu/P7687/data/net9.out
(Stored with Git LFS)
Normal file
BIN
Luogu/P7687/data/net9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user