Submission #90861

#TimeUsernameProblemLanguageResultExecution timeMemory
90861daniel_02Shymbulak (IZhO14_shymbulak)C++17
50 / 100
1569 ms11476 KiB
#include <bits/stdc++.h> #define fr first #define pb push_back #define sc second #define ll long long using namespace std; const int N = 2e5 + 7; const int inf = 1e6 + 7; vector<int>g[N]; int d[N]; int cn[N]; queue<pair<int, int>>q; void mems(){ for (int i = 0; i < N; i++) d[i] = inf; queue<pair<int, int>>empty; swap(q, empty); } void dance(int a) { mems(); q.push({a, 0}); d[a] = 0; while (!q.empty()) { int v = q.front().fr, cs = q.front().sc; q.pop(); if (cs > d[v])continue; for (int i = 0; i < g[v].size(); i++) { int to = g[v][i]; if (cs + 1 <= d[to]) { d[to] = cs + 1; cn[d[to]]++; q.push({to, d[to]}); } } } } main() { int n; cin >> n; for (int i = 1; i <= n; i++) { int a, b; scanf("%d%d", &a, &b); g[a].pb(b); g[b].pb(a); } int mx = 0; for (int i = 1; i <= n; i++) { dance(i); for (int j = 1; j <= n; j++) { if (i == j)continue; mx = max(mx, d[j]); } } cout << cn[mx] / 2 << endl; }

Compilation message (stderr)

shymbulak.cpp: In function 'void dance(int)':
shymbulak.cpp:35:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < g[v].size(); i++)
                   ~~^~~~~~~~~~~~~
shymbulak.cpp: At global scope:
shymbulak.cpp:48:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
shymbulak.cpp: In function 'int main()':
shymbulak.cpp:57:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &a, &b);
   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...