Submission #982953

#TimeUsernameProblemLanguageResultExecution timeMemory
982953vjudge1Duathlon (APIO18_duathlon)C++17
0 / 100
1062 ms18776 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...