답안 #158233

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
158233 2019-10-15T16:09:03 Z maruii 철인 이종 경기 (APIO18_duathlon) C++14
49 / 100
1000 ms 1048576 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define ff first
#define ss second

int n, N, M, dfn[100005], dfnn, low[100005], cpnn, sz[100005], Gn;
vector<int> edge[100005], bdge[200005];
ll ans;
bool vis[100005];

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) {
	vis[x] = 1;
	if (c) {
		bdge[c].push_back(x);
		bdge[x].push_back(c);
	}
	for (auto i : edge[x]) {
		if (vis[i]) continue;
		if (low[i] >= dfn[x]) {
			++cpnn;
			bdge[x].push_back(cpnn);
			bdge[cpnn].push_back(x);
			bcc(i, cpnn);
		}
		else bcc(i, c);
	}
}

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

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);
	}
	cpnn = n;
	for (int i = 1; i <= n; ++i) {
		if (dfn[i]) continue;
		N = 0;
		dfs(i, 0);
		ans += 1ll * N * (N - 1) * (N - 2);
		bcc(i, 0);
		calc(i, 0);
	}
	cout << ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7416 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 8 ms 7416 KB Output is correct
4 Correct 8 ms 7416 KB Output is correct
5 Correct 8 ms 7416 KB Output is correct
6 Correct 8 ms 7416 KB Output is correct
7 Correct 8 ms 7416 KB Output is correct
8 Correct 9 ms 7388 KB Output is correct
9 Correct 8 ms 7544 KB Output is correct
10 Correct 9 ms 7416 KB Output is correct
11 Correct 9 ms 7416 KB Output is correct
12 Correct 8 ms 7416 KB Output is correct
13 Correct 8 ms 7416 KB Output is correct
14 Correct 9 ms 7416 KB Output is correct
15 Correct 8 ms 7416 KB Output is correct
16 Correct 9 ms 7416 KB Output is correct
17 Correct 8 ms 7420 KB Output is correct
18 Correct 8 ms 7416 KB Output is correct
19 Correct 8 ms 7416 KB Output is correct
20 Correct 8 ms 7416 KB Output is correct
21 Correct 8 ms 7416 KB Output is correct
22 Correct 9 ms 7416 KB Output is correct
23 Correct 9 ms 7416 KB Output is correct
24 Correct 9 ms 7416 KB Output is correct
25 Correct 10 ms 7416 KB Output is correct
26 Correct 10 ms 7544 KB Output is correct
27 Correct 10 ms 7416 KB Output is correct
28 Correct 9 ms 7416 KB Output is correct
29 Correct 10 ms 7416 KB Output is correct
30 Correct 11 ms 7416 KB Output is correct
31 Correct 10 ms 7416 KB Output is correct
32 Correct 10 ms 7416 KB Output is correct
33 Correct 10 ms 7416 KB Output is correct
34 Correct 8 ms 7416 KB Output is correct
35 Correct 8 ms 7416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7416 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 8 ms 7416 KB Output is correct
4 Correct 8 ms 7416 KB Output is correct
5 Correct 8 ms 7416 KB Output is correct
6 Correct 8 ms 7416 KB Output is correct
7 Correct 8 ms 7416 KB Output is correct
8 Correct 9 ms 7388 KB Output is correct
9 Correct 8 ms 7544 KB Output is correct
10 Correct 9 ms 7416 KB Output is correct
11 Correct 9 ms 7416 KB Output is correct
12 Correct 8 ms 7416 KB Output is correct
13 Correct 8 ms 7416 KB Output is correct
14 Correct 9 ms 7416 KB Output is correct
15 Correct 8 ms 7416 KB Output is correct
16 Correct 9 ms 7416 KB Output is correct
17 Correct 8 ms 7420 KB Output is correct
18 Correct 8 ms 7416 KB Output is correct
19 Correct 8 ms 7416 KB Output is correct
20 Correct 8 ms 7416 KB Output is correct
21 Correct 8 ms 7416 KB Output is correct
22 Correct 9 ms 7416 KB Output is correct
23 Correct 9 ms 7416 KB Output is correct
24 Correct 9 ms 7416 KB Output is correct
25 Correct 10 ms 7416 KB Output is correct
26 Correct 10 ms 7544 KB Output is correct
27 Correct 10 ms 7416 KB Output is correct
28 Correct 9 ms 7416 KB Output is correct
29 Correct 10 ms 7416 KB Output is correct
30 Correct 11 ms 7416 KB Output is correct
31 Correct 10 ms 7416 KB Output is correct
32 Correct 10 ms 7416 KB Output is correct
33 Correct 10 ms 7416 KB Output is correct
34 Correct 8 ms 7416 KB Output is correct
35 Correct 8 ms 7416 KB Output is correct
36 Correct 8 ms 7416 KB Output is correct
37 Correct 8 ms 7416 KB Output is correct
38 Correct 9 ms 7428 KB Output is correct
39 Correct 10 ms 7420 KB Output is correct
40 Correct 11 ms 7432 KB Output is correct
41 Correct 11 ms 7416 KB Output is correct
42 Correct 8 ms 7416 KB Output is correct
43 Correct 9 ms 7416 KB Output is correct
44 Correct 10 ms 7416 KB Output is correct
45 Correct 10 ms 7416 KB Output is correct
46 Correct 9 ms 7416 KB Output is correct
47 Correct 9 ms 7416 KB Output is correct
48 Correct 8 ms 7416 KB Output is correct
49 Correct 9 ms 7416 KB Output is correct
50 Correct 8 ms 7416 KB Output is correct
51 Correct 8 ms 7416 KB Output is correct
52 Correct 8 ms 7416 KB Output is correct
53 Correct 8 ms 7416 KB Output is correct
54 Correct 8 ms 7420 KB Output is correct
55 Correct 10 ms 7416 KB Output is correct
56 Correct 10 ms 7416 KB Output is correct
57 Correct 8 ms 7416 KB Output is correct
58 Correct 8 ms 7416 KB Output is correct
59 Correct 8 ms 7416 KB Output is correct
60 Correct 8 ms 7416 KB Output is correct
61 Correct 8 ms 7416 KB Output is correct
62 Correct 8 ms 7416 KB Output is correct
63 Correct 9 ms 7416 KB Output is correct
64 Correct 8 ms 7416 KB Output is correct
65 Correct 8 ms 7420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 134 ms 23056 KB Output is correct
2 Correct 120 ms 22896 KB Output is correct
3 Correct 180 ms 24456 KB Output is correct
4 Incorrect 129 ms 21876 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7544 KB Output is correct
2 Correct 9 ms 7544 KB Output is correct
3 Correct 9 ms 7544 KB Output is correct
4 Correct 9 ms 7672 KB Output is correct
5 Correct 10 ms 7672 KB Output is correct
6 Correct 11 ms 7544 KB Output is correct
7 Correct 11 ms 7672 KB Output is correct
8 Correct 9 ms 7676 KB Output is correct
9 Correct 9 ms 7544 KB Output is correct
10 Correct 9 ms 7544 KB Output is correct
11 Correct 9 ms 7544 KB Output is correct
12 Correct 9 ms 7672 KB Output is correct
13 Correct 9 ms 7468 KB Output is correct
14 Correct 9 ms 7544 KB Output is correct
15 Correct 9 ms 7544 KB Output is correct
16 Correct 9 ms 7544 KB Output is correct
17 Correct 8 ms 7544 KB Output is correct
18 Correct 9 ms 7544 KB Output is correct
19 Correct 9 ms 7544 KB Output is correct
20 Correct 10 ms 7532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 130 ms 19648 KB Output is correct
2 Correct 131 ms 19448 KB Output is correct
3 Correct 139 ms 19704 KB Output is correct
4 Correct 137 ms 19548 KB Output is correct
5 Correct 174 ms 19596 KB Output is correct
6 Correct 161 ms 27872 KB Output is correct
7 Correct 152 ms 24956 KB Output is correct
8 Correct 155 ms 23568 KB Output is correct
9 Correct 142 ms 22188 KB Output is correct
10 Execution timed out 1086 ms 1048576 KB Time limit exceeded
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7544 KB Output is correct
2 Correct 9 ms 7544 KB Output is correct
3 Correct 13 ms 7544 KB Output is correct
4 Correct 9 ms 7524 KB Output is correct
5 Correct 11 ms 7416 KB Output is correct
6 Correct 11 ms 7544 KB Output is correct
7 Correct 9 ms 7416 KB Output is correct
8 Correct 11 ms 7548 KB Output is correct
9 Correct 12 ms 7516 KB Output is correct
10 Correct 10 ms 7548 KB Output is correct
11 Correct 24 ms 7516 KB Output is correct
12 Correct 11 ms 7544 KB Output is correct
13 Correct 10 ms 7544 KB Output is correct
14 Correct 9 ms 7548 KB Output is correct
15 Correct 9 ms 7544 KB Output is correct
16 Correct 9 ms 7516 KB Output is correct
17 Correct 9 ms 7544 KB Output is correct
18 Correct 9 ms 7544 KB Output is correct
19 Correct 9 ms 7544 KB Output is correct
20 Correct 9 ms 7544 KB Output is correct
21 Correct 9 ms 7544 KB Output is correct
22 Correct 10 ms 7548 KB Output is correct
23 Correct 11 ms 7516 KB Output is correct
24 Correct 10 ms 7544 KB Output is correct
25 Correct 9 ms 7416 KB Output is correct
26 Correct 8 ms 7416 KB Output is correct
27 Correct 8 ms 7416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 141 ms 19476 KB Output is correct
2 Correct 141 ms 19448 KB Output is correct
3 Correct 210 ms 19064 KB Output is correct
4 Correct 218 ms 18424 KB Output is correct
5 Correct 203 ms 17748 KB Output is correct
6 Correct 187 ms 17464 KB Output is correct
7 Correct 119 ms 17320 KB Output is correct
8 Correct 134 ms 17028 KB Output is correct
9 Correct 162 ms 17016 KB Output is correct
10 Correct 176 ms 17020 KB Output is correct
11 Correct 119 ms 16888 KB Output is correct
12 Correct 99 ms 17048 KB Output is correct
13 Correct 105 ms 16888 KB Output is correct
14 Correct 103 ms 18296 KB Output is correct
15 Correct 166 ms 24952 KB Output is correct
16 Correct 168 ms 22896 KB Output is correct
17 Correct 146 ms 23832 KB Output is correct
18 Correct 140 ms 22008 KB Output is correct
19 Execution timed out 1142 ms 1043328 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7416 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 8 ms 7416 KB Output is correct
4 Correct 8 ms 7416 KB Output is correct
5 Correct 8 ms 7416 KB Output is correct
6 Correct 8 ms 7416 KB Output is correct
7 Correct 8 ms 7416 KB Output is correct
8 Correct 9 ms 7388 KB Output is correct
9 Correct 8 ms 7544 KB Output is correct
10 Correct 9 ms 7416 KB Output is correct
11 Correct 9 ms 7416 KB Output is correct
12 Correct 8 ms 7416 KB Output is correct
13 Correct 8 ms 7416 KB Output is correct
14 Correct 9 ms 7416 KB Output is correct
15 Correct 8 ms 7416 KB Output is correct
16 Correct 9 ms 7416 KB Output is correct
17 Correct 8 ms 7420 KB Output is correct
18 Correct 8 ms 7416 KB Output is correct
19 Correct 8 ms 7416 KB Output is correct
20 Correct 8 ms 7416 KB Output is correct
21 Correct 8 ms 7416 KB Output is correct
22 Correct 9 ms 7416 KB Output is correct
23 Correct 9 ms 7416 KB Output is correct
24 Correct 9 ms 7416 KB Output is correct
25 Correct 10 ms 7416 KB Output is correct
26 Correct 10 ms 7544 KB Output is correct
27 Correct 10 ms 7416 KB Output is correct
28 Correct 9 ms 7416 KB Output is correct
29 Correct 10 ms 7416 KB Output is correct
30 Correct 11 ms 7416 KB Output is correct
31 Correct 10 ms 7416 KB Output is correct
32 Correct 10 ms 7416 KB Output is correct
33 Correct 10 ms 7416 KB Output is correct
34 Correct 8 ms 7416 KB Output is correct
35 Correct 8 ms 7416 KB Output is correct
36 Correct 8 ms 7416 KB Output is correct
37 Correct 8 ms 7416 KB Output is correct
38 Correct 9 ms 7428 KB Output is correct
39 Correct 10 ms 7420 KB Output is correct
40 Correct 11 ms 7432 KB Output is correct
41 Correct 11 ms 7416 KB Output is correct
42 Correct 8 ms 7416 KB Output is correct
43 Correct 9 ms 7416 KB Output is correct
44 Correct 10 ms 7416 KB Output is correct
45 Correct 10 ms 7416 KB Output is correct
46 Correct 9 ms 7416 KB Output is correct
47 Correct 9 ms 7416 KB Output is correct
48 Correct 8 ms 7416 KB Output is correct
49 Correct 9 ms 7416 KB Output is correct
50 Correct 8 ms 7416 KB Output is correct
51 Correct 8 ms 7416 KB Output is correct
52 Correct 8 ms 7416 KB Output is correct
53 Correct 8 ms 7416 KB Output is correct
54 Correct 8 ms 7420 KB Output is correct
55 Correct 10 ms 7416 KB Output is correct
56 Correct 10 ms 7416 KB Output is correct
57 Correct 8 ms 7416 KB Output is correct
58 Correct 8 ms 7416 KB Output is correct
59 Correct 8 ms 7416 KB Output is correct
60 Correct 8 ms 7416 KB Output is correct
61 Correct 8 ms 7416 KB Output is correct
62 Correct 8 ms 7416 KB Output is correct
63 Correct 9 ms 7416 KB Output is correct
64 Correct 8 ms 7416 KB Output is correct
65 Correct 8 ms 7420 KB Output is correct
66 Correct 8 ms 7392 KB Output is correct
67 Correct 9 ms 7544 KB Output is correct
68 Correct 9 ms 7544 KB Output is correct
69 Correct 9 ms 7544 KB Output is correct
70 Correct 9 ms 7672 KB Output is correct
71 Correct 9 ms 7544 KB Output is correct
72 Correct 11 ms 7544 KB Output is correct
73 Correct 10 ms 7416 KB Output is correct
74 Correct 11 ms 7544 KB Output is correct
75 Correct 11 ms 7416 KB Output is correct
76 Correct 9 ms 7416 KB Output is correct
77 Correct 10 ms 7544 KB Output is correct
78 Correct 9 ms 7544 KB Output is correct
79 Correct 9 ms 7544 KB Output is correct
80 Correct 11 ms 7544 KB Output is correct
81 Correct 10 ms 7544 KB Output is correct
82 Correct 10 ms 7544 KB Output is correct
83 Correct 11 ms 7576 KB Output is correct
84 Correct 9 ms 7544 KB Output is correct
85 Correct 11 ms 7544 KB Output is correct
86 Correct 11 ms 7548 KB Output is correct
87 Correct 11 ms 7544 KB Output is correct
88 Correct 12 ms 7544 KB Output is correct
89 Correct 11 ms 7544 KB Output is correct
90 Correct 11 ms 7544 KB Output is correct
91 Correct 9 ms 7544 KB Output is correct
92 Correct 11 ms 7544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7416 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 8 ms 7416 KB Output is correct
4 Correct 8 ms 7416 KB Output is correct
5 Correct 8 ms 7416 KB Output is correct
6 Correct 8 ms 7416 KB Output is correct
7 Correct 8 ms 7416 KB Output is correct
8 Correct 9 ms 7388 KB Output is correct
9 Correct 8 ms 7544 KB Output is correct
10 Correct 9 ms 7416 KB Output is correct
11 Correct 9 ms 7416 KB Output is correct
12 Correct 8 ms 7416 KB Output is correct
13 Correct 8 ms 7416 KB Output is correct
14 Correct 9 ms 7416 KB Output is correct
15 Correct 8 ms 7416 KB Output is correct
16 Correct 9 ms 7416 KB Output is correct
17 Correct 8 ms 7420 KB Output is correct
18 Correct 8 ms 7416 KB Output is correct
19 Correct 8 ms 7416 KB Output is correct
20 Correct 8 ms 7416 KB Output is correct
21 Correct 8 ms 7416 KB Output is correct
22 Correct 9 ms 7416 KB Output is correct
23 Correct 9 ms 7416 KB Output is correct
24 Correct 9 ms 7416 KB Output is correct
25 Correct 10 ms 7416 KB Output is correct
26 Correct 10 ms 7544 KB Output is correct
27 Correct 10 ms 7416 KB Output is correct
28 Correct 9 ms 7416 KB Output is correct
29 Correct 10 ms 7416 KB Output is correct
30 Correct 11 ms 7416 KB Output is correct
31 Correct 10 ms 7416 KB Output is correct
32 Correct 10 ms 7416 KB Output is correct
33 Correct 10 ms 7416 KB Output is correct
34 Correct 8 ms 7416 KB Output is correct
35 Correct 8 ms 7416 KB Output is correct
36 Correct 8 ms 7416 KB Output is correct
37 Correct 8 ms 7416 KB Output is correct
38 Correct 9 ms 7428 KB Output is correct
39 Correct 10 ms 7420 KB Output is correct
40 Correct 11 ms 7432 KB Output is correct
41 Correct 11 ms 7416 KB Output is correct
42 Correct 8 ms 7416 KB Output is correct
43 Correct 9 ms 7416 KB Output is correct
44 Correct 10 ms 7416 KB Output is correct
45 Correct 10 ms 7416 KB Output is correct
46 Correct 9 ms 7416 KB Output is correct
47 Correct 9 ms 7416 KB Output is correct
48 Correct 8 ms 7416 KB Output is correct
49 Correct 9 ms 7416 KB Output is correct
50 Correct 8 ms 7416 KB Output is correct
51 Correct 8 ms 7416 KB Output is correct
52 Correct 8 ms 7416 KB Output is correct
53 Correct 8 ms 7416 KB Output is correct
54 Correct 8 ms 7420 KB Output is correct
55 Correct 10 ms 7416 KB Output is correct
56 Correct 10 ms 7416 KB Output is correct
57 Correct 8 ms 7416 KB Output is correct
58 Correct 8 ms 7416 KB Output is correct
59 Correct 8 ms 7416 KB Output is correct
60 Correct 8 ms 7416 KB Output is correct
61 Correct 8 ms 7416 KB Output is correct
62 Correct 8 ms 7416 KB Output is correct
63 Correct 9 ms 7416 KB Output is correct
64 Correct 8 ms 7416 KB Output is correct
65 Correct 8 ms 7420 KB Output is correct
66 Correct 134 ms 23056 KB Output is correct
67 Correct 120 ms 22896 KB Output is correct
68 Correct 180 ms 24456 KB Output is correct
69 Incorrect 129 ms 21876 KB Output isn't correct
70 Halted 0 ms 0 KB -