# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
37876 | Just_Solve_The_Problem | Shymbulak (IZhO14_shymbulak) | C++11 | 1500 ms | 8176 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
const int N = (int)1e5 + 7;
vector < int > gr[N];
int used[N];
int ans[N];
pair < int, int > otv;
void dfs (int v, int h = 0) {
used[v] = h;
ans[v] = 1;
for (int to : gr[v]) {
if (h + 1 < used[to]) {
dfs(to, h + 1);
} else if (h + 1 == used[to]) {
ans[to]++;
}
}
}
main () {
int n; scanf ("%d", &n);
for (int i = 1; i <= n; i++) {
int u, v; scanf ("%d %d", &u, &v);
gr[u].pb(v);
gr[v].pb(u);
}
pair < int, int > res;
res = {0, 0};
for (int i = 1; i <= n; i++) {
memset(used, 63, sizeof(used));
dfs(i);
for (int j = 1; j <= n; j++) {
if (used[j] > res.fr) {
res.fr = used[j];
res.sc = ans[j];
} else if (used[j] == res.fr) {
res.sc += ans[j];
}
}
}
cout << res.sc - 2;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |