답안 #405082

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
405082 2021-05-15T16:48:04 Z BERNARB01 철인 이종 경기 (APIO18_duathlon) C++17
23 / 100
1000 ms 1048580 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		--u; --v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	vector<long long> sbt(n, 0);
	long long ans = 0;
	function<void(int, int)> dfs0 = [&](int u, int p) {
		sbt[u] = 1;
		for (int v : g[u]) {
			if (v != p) {
				dfs0(v, u);
				sbt[u] += sbt[v];
			}
		}
	};
	function<void(int, int, int)> DFS = [&](int u, int p, int nn) {
		for (int v : g[u]) {
			if (v != p) {
				DFS(v, u, nn);
			}
		}
		long long sum = nn - 1;
		long long sbtp = nn - sbt[u];
		ans += sbtp * 1LL * (sum - sbtp);
		for (int v : g[u]) {
			if (v != p) {
				ans += sbt[v] * 1LL * (sum - sbt[v]);
			}
		}
	};
	for (int i = 0; i < n; i++) {
		if (sbt[i] == 0) {
			dfs0(i, -1);
			DFS(i, -1, sbt[i]);
		}
	}
	cout << ans << '\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 584 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 584 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1121 ms 653648 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 1 ms 320 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 6632 KB Output is correct
2 Correct 58 ms 6612 KB Output is correct
3 Correct 56 ms 6624 KB Output is correct
4 Correct 58 ms 6648 KB Output is correct
5 Correct 68 ms 6580 KB Output is correct
6 Correct 86 ms 13348 KB Output is correct
7 Correct 75 ms 11076 KB Output is correct
8 Correct 70 ms 9852 KB Output is correct
9 Correct 68 ms 8852 KB Output is correct
10 Correct 60 ms 6648 KB Output is correct
11 Correct 69 ms 8004 KB Output is correct
12 Correct 74 ms 7924 KB Output is correct
13 Correct 59 ms 7840 KB Output is correct
14 Correct 51 ms 7640 KB Output is correct
15 Correct 45 ms 7364 KB Output is correct
16 Correct 42 ms 6384 KB Output is correct
17 Correct 38 ms 8148 KB Output is correct
18 Correct 39 ms 8128 KB Output is correct
19 Correct 40 ms 8120 KB Output is correct
20 Correct 46 ms 8172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Runtime error 732 ms 1048580 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 6600 KB Output is correct
2 Correct 67 ms 6556 KB Output is correct
3 Runtime error 918 ms 1048580 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 584 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 584 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -