0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 19:08:47 +00:00

#2104. 【模板】割点(割顶)

https://sjzezoj.com/submission/74885
This commit is contained in:
Baoshuo Ren 2023-03-30 17:29:56 +08:00
parent ee1b36802f
commit e05182f7cd
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
55 changed files with 278 additions and 0 deletions

68
S2OJ/2104/2104.cpp Normal file
View File

@ -0,0 +1,68 @@
#include <iostream>
#include <algorithm>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 2e4 + 5;
int n, m;
std::vector<int> g[N];
int root, cnt, dfn[N], low[N];
bool cut[N];
void tarjan(int u) {
dfn[u] = low[u] = ++cnt;
bool flag = false;
for (int v : g[u]) {
if (!dfn[v]) {
tarjan(v);
low[u] = std::min(low[u], low[v]);
if (dfn[u] <= low[v]) {
if (u != root || flag) {
cut[u] = true;
} else {
flag = true;
}
}
} else {
low[u] = std::min(low[u], dfn[v]);
}
}
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1, x, y; i <= m; i++) {
cin >> x >> y;
g[x].emplace_back(y);
g[y].emplace_back(x);
}
for (int i = 1; i <= n; i++) {
if (!dfn[i]) {
root = i;
tarjan(i);
}
}
cout << std::count(cut + 1, cut + n + 1, true) << endl;
for (int i = 1; i <= n; i++) {
if (cut[i]) {
cout << i << ' ';
}
}
cout << endl;
return 0;
}

BIN
S2OJ/2104/data/1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/12.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/12.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/13.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/13.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/14.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/14.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/15.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/15.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/16.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/16.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/17.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/17.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/18.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/18.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/19.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/19.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/20.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/20.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/21.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/21.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/22.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/22.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/23.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/23.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/24.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/24.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/25.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/25.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/9.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/problem.conf (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/std.cpp (Stored with Git LFS) Normal file

Binary file not shown.

BIN
S2OJ/2104/data/val.cpp (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,51 @@
/**
* @file S2OJ/2104/gen.cpp
* @author Baoshuo <i@baoshuo.ren>
* @url https://baoshuo.ren
* @license GPL-3.0
* @date 2023-03-30
*/
#include "testlib.h"
#include <iostream>
#include <limits>
using std::cin;
using std::cout;
const char endl = '\n';
#define N_TESTS 25
#define PERCENT_TESTS(_percent) (static_cast<double>(_percent) / 100 * N_TESTS)
int main(int argc, char* argv[]) {
registerGen(argc, argv, 1);
int id = opt<int>("id");
int min_n = 10000,
max_n = 20000;
int min_m = 50000,
max_m = 100000;
if (id <= PERCENT_TESTS(30)) {
min_n = 500, max_n = 1000;
min_m = 1000, max_m = 5000;
} else { // all tests
// (none)
}
int n = rnd.next(min_n, max_n);
int m = rnd.next(min_m, max_m);
cout << n << ' ' << m << endl;
for (int i = 1; i <= m; i++) {
int u = rnd.next(1, n);
int v = rnd.next(1, n);
cout << u << ' ' << v << endl;
}
return 0;
}