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

1123. [POI2008]BLO

https://hydro.ac/d/bzoj/record/6329c21479b7c59ccd1f3d9e
This commit is contained in:
Baoshuo Ren 2022-09-20 21:37:38 +08:00
parent 6f733038c4
commit b238b8ee8b
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
33 changed files with 173 additions and 0 deletions

77
BZOJ/1123/1123.cpp Normal file
View File

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

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.