Submission #833898

#TimeUsernameProblemLanguageResultExecution timeMemory
833898BilAktauAlmansurShymbulak (IZhO14_shymbulak)C++17
50 / 100
1537 ms10316 KiB
#include <bits/stdc++.h> #pragma optimize ("g",on) #pragma GCC optimize ("inline") #pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize ("03") #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native") #pragma comment(linker, "/stack:200000000") // #define int long long using namespace std; const int N = 2e5 + 7; vector<vector<int> > g(N); signed main() { // freopen("bank.in", "r", stdin); // freopen("bank.out", "w", stdout); ios_base::sync_with_stdio(NULL); cin.tie(NULL); int n; cin>>n; for(int i = 1; i <= n; i++) { int x, y; cin>>x>>y; g[x].push_back(y); g[y].push_back(x); } int cnt = 0, ans = 0; for(int i = 1; i <= n; i++) { queue<int> q; q.push(i); vector<int> us(n + 1, 0), d(n + 1, 0), cn(n + 1, 1); us[i] = 1; while(!q.empty()) { int v = q.front(); q.pop(); for(auto to : g[v]) { if(!us[to]) { us[to] = 1; d[to] = d[v] + 1, cn[to] = cn[v]; q.push(to); }else { if(d[to] == d[v] + 1)cn[to] ++; } } } for(int j = 1; j <= n; j++) { if(d[j] > cnt) { cnt = d[j], ans = cn[j]; }else if(d[j] == cnt)ans += cn[j]; } } cout << ans / 2 << '\n'; }

Compilation message (stderr)

shymbulak.cpp:2: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    2 | #pragma optimize ("g",on)
      | 
shymbulak.cpp:8: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    8 | #pragma comment(linker, "/stack:200000000")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...