답안 #158203

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
158203 2019-10-15T13:26:50 Z maruii 철인 이종 경기 (APIO18_duathlon) C++14
0 / 100
127 ms 17144 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;
	N++;
	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);
	int n; 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);
	}
	for (int i = 1; i <= n; ++i) {
		if (dfn[i]) continue;
		N = 0;
		dfs(i, i);
		bcc(i, ++cpnn);
		calc(i, i);
	}
	cout << ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 5112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 5112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 15608 KB Output is correct
2 Correct 82 ms 15608 KB Output is correct
3 Correct 77 ms 14328 KB Output is correct
4 Incorrect 95 ms 16196 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 5112 KB Output is correct
2 Correct 6 ms 5112 KB Output is correct
3 Correct 6 ms 5112 KB Output is correct
4 Correct 6 ms 5112 KB Output is correct
5 Correct 6 ms 5112 KB Output is correct
6 Correct 6 ms 5044 KB Output is correct
7 Correct 6 ms 5240 KB Output is correct
8 Correct 6 ms 5112 KB Output is correct
9 Correct 6 ms 5240 KB Output is correct
10 Incorrect 6 ms 5112 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 13024 KB Output is correct
2 Correct 95 ms 13120 KB Output is correct
3 Correct 93 ms 13152 KB Output is correct
4 Correct 77 ms 13048 KB Output is correct
5 Correct 78 ms 13064 KB Output is correct
6 Correct 89 ms 17144 KB Output is correct
7 Correct 94 ms 15736 KB Output is correct
8 Correct 86 ms 14964 KB Output is correct
9 Correct 115 ms 14288 KB Output is correct
10 Incorrect 121 ms 13228 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 5112 KB Output is correct
2 Correct 6 ms 5112 KB Output is correct
3 Incorrect 8 ms 5084 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 127 ms 13132 KB Output is correct
2 Correct 80 ms 12912 KB Output is correct
3 Incorrect 82 ms 11812 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 5112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 5112 KB Output isn't correct
2 Halted 0 ms 0 KB -