Submission #982953

# Submission time Handle Problem Language Result Execution time Memory
982953 2024-05-15T06:02:54 Z vjudge1 Duathlon (APIO18_duathlon) C++17
0 / 100
1000 ms 18776 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, m, i, j, x, y, ans, dst[2001][2001];
bool u[2001][2001];
vector<int> g[200001];

signed main() {
	cin.tie(0)->sync_with_stdio(0);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	#endif
	cin >> n >> m;
	while (m--) {
		cin >> x >> y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) u[i][j] = 0;
		queue<int> q;
		u[i][i] = 1;
		q.push(i);
		while (q.size()) {
			x = q.front();
			q.pop();
			for (auto y : g[x]) {
				if (!u[i][y]) {
					u[i][y] = 1;
					dst[i][y] = dst[i][x] + 1;
					q.push(y);
				}
			}
		}
	}
	for (int c = 1; c <= n; c++) {
		for (int s = 1; s <= n; s++) {
			for (int f = 1; f <= n; f++) {
				if (s == c || s == f || c == f) continue;
				if (u[s][c] && u[c][f] && max({dst[s][c], dst[c][f], dst[s][f]}) == dst[s][f]) {
					ans++;
					//cout << s << " " << c << " " << f << "\n";
				}
			}
		}
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 16584 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1008 ms 18776 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1006 ms 13020 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1032 ms 18772 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 15956 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 5108 KB Output isn't correct
2 Halted 0 ms 0 KB -