Submission #1115763

# Submission time Handle Problem Language Result Execution time Memory
1115763 2024-11-20T23:44:19 Z gustavo_d Duathlon (APIO18_duathlon) C++17
0 / 100
34 ms 9032 KB
// https://oj.uz/problem/view/APIO18_duathlon > p520
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int MAXN = 1e5;
vector<int> adj[MAXN];
bool vis[MAXN];

int dfs(int v) {
	vis[v] = true;
	int sz = 1;
	for (int viz : adj[v]) {
		if (vis[viz]) continue;
		sz += dfs(viz);
	}
	return sz;
}

ll qty(int n) {
	if (n < 3) return 0;
	return (ll)(n) * (ll)(n - 1) * (ll)(n - 2) / 3LL;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);

	int n, m; cin >> n >> m;
	for (int i=0; i<m; i++) {
		int u, v; cin >> u >> v;
		u--; v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	ll ans = 0;
	for (int i=0; i<n; i++) {
		if (vis[i]) continue;
		ans += qty(dfs(i));
	}
	cout << ans << '\n';

	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 34 ms 9032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 6080 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 5968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2640 KB Output isn't correct
2 Halted 0 ms 0 KB -