Submission #37876

#TimeUsernameProblemLanguageResultExecution timeMemory
37876Just_Solve_The_ProblemShymbulak (IZhO14_shymbulak)C++11
0 / 100
1500 ms8176 KiB
#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)

shymbulak.cpp:28:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main () {
       ^
shymbulak.cpp: In function 'int main()':
shymbulak.cpp:29:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int n; scanf ("%d", &n);
                            ^
shymbulak.cpp:31:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int u, v; scanf ("%d %d", &u, &v);
                                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...