답안 #727611

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
727611 2023-04-21T02:58:39 Z SanguineChameleon 철인 이종 경기 (APIO18_duathlon) C++17
24 / 100
53 ms 10240 KB
#include <bits/stdc++.h>
using namespace std;

void just_do_it();

int main() {
	#ifdef KAMIRULEZ
		freopen("kamirulez.inp", "r", stdin);
		freopen("kamirulez.out", "w", stdout);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	just_do_it();
	return 0;
}

const int maxn = 1e5 + 20;
vector<int> adj[maxn];
bool can[55][55][55];
bool bad[maxn];
bool flag[maxn];
int node_cnt = 0;
int edge_cnt = 0;
int n, m;

void dfs(int x, int a, int b) {
	can[x][a][b] = true;
	for (auto c: adj[b]) {
		if (c != x && !can[x][a][c]) {
			dfs(x, a, c);
		}
	}
}

void dfs(int u) {
	flag[u] = true;
	node_cnt++;
	edge_cnt += adj[u].size();
	for (auto v: adj[u]) {
		if (!flag[v]) {
			dfs(v);
		}
	}
}

void sub1() {
	for (int x = 1; x <= n; x++) {
		for (int a = 1; a <= n; a++) {
			if (a != x) {
				dfs(x, a, a);
			}
		}
		bad[x] = false;
	}
	int res = 0;
	for (int a = 1; a <= n; a++) {
		for (int b = 1; b <= n; b++) {
			if (b == a) {
				continue;
			}
			for (int c = 1; c <= n; c++) {
				if (c == a || c == b) {
					continue;
				}
				bool ok = true;
				for (int x = 1; x <= n; x++) {
					if (x == b) {
						continue;
					}
					if (!can[x][a][b] && !can[x][b][c]) {
						ok = false;
						break;
					}
				}
				if (ok) {
					res++;
				}
			}
		}
	}
	cout << res;
}

long long solve(int root) {
	node_cnt = 0;
	edge_cnt = 0;
	dfs(root);
	edge_cnt /= 2;
	if (node_cnt == edge_cnt) {
		return 1LL * node_cnt * (node_cnt - 1) * (node_cnt - 2);
	}
	else {
		return 1LL * node_cnt * (node_cnt - 1) * (node_cnt - 2) / 3;
	}
}

void just_do_it() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	if (n <= 50) {
		sub1();
		return;
	}
	long long res = 0;
	for (int i = 1; i <= n; i++) {
		if (!flag[i]) {
			res += solve(i);
		}
	}
	cout << res;
	return;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2664 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2680 KB Output is correct
6 Correct 2 ms 2772 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2676 KB Output is correct
9 Correct 2 ms 2680 KB Output is correct
10 Correct 2 ms 2680 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 2 ms 2644 KB Output is correct
13 Correct 2 ms 2680 KB Output is correct
14 Correct 2 ms 2680 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 2 ms 2772 KB Output is correct
17 Correct 2 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2676 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 2 ms 2644 KB Output is correct
25 Correct 2 ms 2684 KB Output is correct
26 Correct 2 ms 2644 KB Output is correct
27 Correct 2 ms 2644 KB Output is correct
28 Correct 2 ms 2644 KB Output is correct
29 Correct 2 ms 2644 KB Output is correct
30 Correct 2 ms 2644 KB Output is correct
31 Correct 2 ms 2644 KB Output is correct
32 Correct 2 ms 2644 KB Output is correct
33 Correct 2 ms 2644 KB Output is correct
34 Correct 2 ms 2676 KB Output is correct
35 Correct 2 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2664 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2680 KB Output is correct
6 Correct 2 ms 2772 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2676 KB Output is correct
9 Correct 2 ms 2680 KB Output is correct
10 Correct 2 ms 2680 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 2 ms 2644 KB Output is correct
13 Correct 2 ms 2680 KB Output is correct
14 Correct 2 ms 2680 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 2 ms 2772 KB Output is correct
17 Correct 2 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2676 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 2 ms 2644 KB Output is correct
25 Correct 2 ms 2684 KB Output is correct
26 Correct 2 ms 2644 KB Output is correct
27 Correct 2 ms 2644 KB Output is correct
28 Correct 2 ms 2644 KB Output is correct
29 Correct 2 ms 2644 KB Output is correct
30 Correct 2 ms 2644 KB Output is correct
31 Correct 2 ms 2644 KB Output is correct
32 Correct 2 ms 2644 KB Output is correct
33 Correct 2 ms 2644 KB Output is correct
34 Correct 2 ms 2676 KB Output is correct
35 Correct 2 ms 2644 KB Output is correct
36 Correct 2 ms 2772 KB Output is correct
37 Correct 2 ms 2772 KB Output is correct
38 Correct 8 ms 2836 KB Output is correct
39 Correct 10 ms 2772 KB Output is correct
40 Correct 11 ms 2772 KB Output is correct
41 Correct 3 ms 2772 KB Output is correct
42 Correct 2 ms 2772 KB Output is correct
43 Correct 2 ms 2808 KB Output is correct
44 Correct 3 ms 2804 KB Output is correct
45 Correct 3 ms 2808 KB Output is correct
46 Correct 3 ms 2808 KB Output is correct
47 Correct 2 ms 2680 KB Output is correct
48 Correct 2 ms 2772 KB Output is correct
49 Correct 2 ms 2772 KB Output is correct
50 Correct 2 ms 2772 KB Output is correct
51 Correct 8 ms 2772 KB Output is correct
52 Correct 6 ms 2808 KB Output is correct
53 Correct 9 ms 2772 KB Output is correct
54 Correct 10 ms 2808 KB Output is correct
55 Correct 11 ms 2812 KB Output is correct
56 Correct 9 ms 2832 KB Output is correct
57 Correct 7 ms 2804 KB Output is correct
58 Correct 8 ms 2804 KB Output is correct
59 Correct 6 ms 2772 KB Output is correct
60 Correct 5 ms 2772 KB Output is correct
61 Correct 4 ms 2772 KB Output is correct
62 Correct 3 ms 2772 KB Output is correct
63 Correct 9 ms 2812 KB Output is correct
64 Correct 9 ms 2836 KB Output is correct
65 Correct 6 ms 2808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 9052 KB Output is correct
2 Correct 41 ms 10240 KB Output is correct
3 Correct 44 ms 8644 KB Output is correct
4 Correct 44 ms 9460 KB Output is correct
5 Correct 48 ms 8172 KB Output is correct
6 Correct 41 ms 8144 KB Output is correct
7 Correct 39 ms 7756 KB Output is correct
8 Correct 40 ms 7884 KB Output is correct
9 Correct 45 ms 7408 KB Output is correct
10 Correct 53 ms 7716 KB Output is correct
11 Correct 34 ms 6820 KB Output is correct
12 Correct 31 ms 6668 KB Output is correct
13 Correct 31 ms 6600 KB Output is correct
14 Correct 30 ms 6476 KB Output is correct
15 Correct 25 ms 6016 KB Output is correct
16 Correct 20 ms 5856 KB Output is correct
17 Correct 2 ms 2772 KB Output is correct
18 Correct 2 ms 2772 KB Output is correct
19 Correct 2 ms 2772 KB Output is correct
20 Correct 2 ms 2772 KB Output is correct
21 Correct 2 ms 2772 KB Output is correct
22 Correct 3 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 6116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 45 ms 6040 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2664 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2680 KB Output is correct
6 Correct 2 ms 2772 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2676 KB Output is correct
9 Correct 2 ms 2680 KB Output is correct
10 Correct 2 ms 2680 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 2 ms 2644 KB Output is correct
13 Correct 2 ms 2680 KB Output is correct
14 Correct 2 ms 2680 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 2 ms 2772 KB Output is correct
17 Correct 2 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2676 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 2 ms 2644 KB Output is correct
25 Correct 2 ms 2684 KB Output is correct
26 Correct 2 ms 2644 KB Output is correct
27 Correct 2 ms 2644 KB Output is correct
28 Correct 2 ms 2644 KB Output is correct
29 Correct 2 ms 2644 KB Output is correct
30 Correct 2 ms 2644 KB Output is correct
31 Correct 2 ms 2644 KB Output is correct
32 Correct 2 ms 2644 KB Output is correct
33 Correct 2 ms 2644 KB Output is correct
34 Correct 2 ms 2676 KB Output is correct
35 Correct 2 ms 2644 KB Output is correct
36 Correct 2 ms 2772 KB Output is correct
37 Correct 2 ms 2772 KB Output is correct
38 Correct 8 ms 2836 KB Output is correct
39 Correct 10 ms 2772 KB Output is correct
40 Correct 11 ms 2772 KB Output is correct
41 Correct 3 ms 2772 KB Output is correct
42 Correct 2 ms 2772 KB Output is correct
43 Correct 2 ms 2808 KB Output is correct
44 Correct 3 ms 2804 KB Output is correct
45 Correct 3 ms 2808 KB Output is correct
46 Correct 3 ms 2808 KB Output is correct
47 Correct 2 ms 2680 KB Output is correct
48 Correct 2 ms 2772 KB Output is correct
49 Correct 2 ms 2772 KB Output is correct
50 Correct 2 ms 2772 KB Output is correct
51 Correct 8 ms 2772 KB Output is correct
52 Correct 6 ms 2808 KB Output is correct
53 Correct 9 ms 2772 KB Output is correct
54 Correct 10 ms 2808 KB Output is correct
55 Correct 11 ms 2812 KB Output is correct
56 Correct 9 ms 2832 KB Output is correct
57 Correct 7 ms 2804 KB Output is correct
58 Correct 8 ms 2804 KB Output is correct
59 Correct 6 ms 2772 KB Output is correct
60 Correct 5 ms 2772 KB Output is correct
61 Correct 4 ms 2772 KB Output is correct
62 Correct 3 ms 2772 KB Output is correct
63 Correct 9 ms 2812 KB Output is correct
64 Correct 9 ms 2836 KB Output is correct
65 Correct 6 ms 2808 KB Output is correct
66 Correct 2 ms 2644 KB Output is correct
67 Incorrect 2 ms 2644 KB Output isn't correct
68 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2664 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2680 KB Output is correct
6 Correct 2 ms 2772 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2676 KB Output is correct
9 Correct 2 ms 2680 KB Output is correct
10 Correct 2 ms 2680 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 2 ms 2644 KB Output is correct
13 Correct 2 ms 2680 KB Output is correct
14 Correct 2 ms 2680 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 2 ms 2772 KB Output is correct
17 Correct 2 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2676 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 2 ms 2644 KB Output is correct
25 Correct 2 ms 2684 KB Output is correct
26 Correct 2 ms 2644 KB Output is correct
27 Correct 2 ms 2644 KB Output is correct
28 Correct 2 ms 2644 KB Output is correct
29 Correct 2 ms 2644 KB Output is correct
30 Correct 2 ms 2644 KB Output is correct
31 Correct 2 ms 2644 KB Output is correct
32 Correct 2 ms 2644 KB Output is correct
33 Correct 2 ms 2644 KB Output is correct
34 Correct 2 ms 2676 KB Output is correct
35 Correct 2 ms 2644 KB Output is correct
36 Correct 2 ms 2772 KB Output is correct
37 Correct 2 ms 2772 KB Output is correct
38 Correct 8 ms 2836 KB Output is correct
39 Correct 10 ms 2772 KB Output is correct
40 Correct 11 ms 2772 KB Output is correct
41 Correct 3 ms 2772 KB Output is correct
42 Correct 2 ms 2772 KB Output is correct
43 Correct 2 ms 2808 KB Output is correct
44 Correct 3 ms 2804 KB Output is correct
45 Correct 3 ms 2808 KB Output is correct
46 Correct 3 ms 2808 KB Output is correct
47 Correct 2 ms 2680 KB Output is correct
48 Correct 2 ms 2772 KB Output is correct
49 Correct 2 ms 2772 KB Output is correct
50 Correct 2 ms 2772 KB Output is correct
51 Correct 8 ms 2772 KB Output is correct
52 Correct 6 ms 2808 KB Output is correct
53 Correct 9 ms 2772 KB Output is correct
54 Correct 10 ms 2808 KB Output is correct
55 Correct 11 ms 2812 KB Output is correct
56 Correct 9 ms 2832 KB Output is correct
57 Correct 7 ms 2804 KB Output is correct
58 Correct 8 ms 2804 KB Output is correct
59 Correct 6 ms 2772 KB Output is correct
60 Correct 5 ms 2772 KB Output is correct
61 Correct 4 ms 2772 KB Output is correct
62 Correct 3 ms 2772 KB Output is correct
63 Correct 9 ms 2812 KB Output is correct
64 Correct 9 ms 2836 KB Output is correct
65 Correct 6 ms 2808 KB Output is correct
66 Correct 38 ms 9052 KB Output is correct
67 Correct 41 ms 10240 KB Output is correct
68 Correct 44 ms 8644 KB Output is correct
69 Correct 44 ms 9460 KB Output is correct
70 Correct 48 ms 8172 KB Output is correct
71 Correct 41 ms 8144 KB Output is correct
72 Correct 39 ms 7756 KB Output is correct
73 Correct 40 ms 7884 KB Output is correct
74 Correct 45 ms 7408 KB Output is correct
75 Correct 53 ms 7716 KB Output is correct
76 Correct 34 ms 6820 KB Output is correct
77 Correct 31 ms 6668 KB Output is correct
78 Correct 31 ms 6600 KB Output is correct
79 Correct 30 ms 6476 KB Output is correct
80 Correct 25 ms 6016 KB Output is correct
81 Correct 20 ms 5856 KB Output is correct
82 Correct 2 ms 2772 KB Output is correct
83 Correct 2 ms 2772 KB Output is correct
84 Correct 2 ms 2772 KB Output is correct
85 Correct 2 ms 2772 KB Output is correct
86 Correct 2 ms 2772 KB Output is correct
87 Correct 3 ms 2772 KB Output is correct
88 Incorrect 2 ms 2644 KB Output isn't correct
89 Halted 0 ms 0 KB -