Submission #158198

# Submission time Handle Problem Language Result Execution time Memory
158198 2019-10-15T12:59:40 Z maruii Duathlon (APIO18_duathlon) C++14
0 / 100
129 ms 18296 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int N, M, dfn[100005], dfnn, low[100005], cpn[100005], cpnn, sz[100005];
vector<int> edge[100005], bdge[100005];
ll ans;

void dfs(int x, int p) {
	dfn[x] = low[x] = ++dfnn;
	for (auto i : edge[x]) {
		if (i == p) continue;
		if (dfn[i]) {
			if (dfn[i] < dfn[x]) low[x] = min(low[x], dfn[i]);
			continue;
		}
		dfs(i, x);
		low[x] = min(low[x], low[i]);
	}
}

void bcc(int x, int c) {
	cpn[x] = c;
	sz[c]++;
	for (auto i : edge[x]) {
		if (cpn[i]) continue;
		if (low[i] == dfn[i]) {
			bdge[++cpnn].push_back(c);
			bdge[c].push_back(cpnn);
			bcc(i, cpnn);
		}
		else bcc(i, c);
	}
}

void calc(int x, int p) {
	ll n = sz[x], t = (N - n) * (N - n);
	ans += n * (n - 1) * (n - 2) + 2 * (n - 1) * (n - 1) * (N - n);
	for (auto i : bdge[x]) {
		if (i == p) continue;
		calc(i, x);
		sz[x] += sz[i];
		t -= 1ll * sz[i] * sz[i];
	}
	ans += n * (t - 1ll * (N - sz[x]) * (N - sz[x]));
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int x, y; cin >> x >> y;
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	dfs(1, 1);
	bcc(1, ++cpnn);
	calc(1, 1);
	cout << ans;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 5240 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 5240 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 79 ms 16828 KB Output is correct
2 Correct 106 ms 16884 KB Output is correct
3 Incorrect 65 ms 13816 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 5112 KB Output is correct
2 Correct 7 ms 5112 KB Output is correct
3 Correct 7 ms 5112 KB Output is correct
4 Correct 6 ms 5240 KB Output is correct
5 Correct 9 ms 5244 KB Output is correct
6 Correct 7 ms 5240 KB Output is correct
7 Correct 6 ms 5112 KB Output is correct
8 Correct 6 ms 5236 KB Output is correct
9 Correct 6 ms 5112 KB Output is correct
10 Incorrect 6 ms 5112 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 83 ms 14296 KB Output is correct
2 Correct 86 ms 14384 KB Output is correct
3 Correct 83 ms 14328 KB Output is correct
4 Correct 87 ms 14332 KB Output is correct
5 Correct 127 ms 14332 KB Output is correct
6 Correct 87 ms 18296 KB Output is correct
7 Correct 129 ms 17024 KB Output is correct
8 Correct 101 ms 16248 KB Output is correct
9 Correct 94 ms 15580 KB Output is correct
10 Incorrect 73 ms 12920 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5112 KB Output is correct
2 Correct 6 ms 5112 KB Output is correct
3 Incorrect 6 ms 5112 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 79 ms 14300 KB Output is correct
2 Correct 79 ms 14200 KB Output is correct
3 Incorrect 93 ms 13364 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 5240 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 5240 KB Output isn't correct
2 Halted 0 ms 0 KB -