# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
673301 | 2022-12-20T06:24:53 Z | Alihan_8 | Shymbulak (IZhO14_shymbulak) | C++17 | 1500 ms | 9392 KB |
#include <bits/stdc++.h> // include <ext/pb_ds/assoc_container.hpp> // include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; using namespace std; #define all(x) x.begin(), x.end() #define pb push_back // define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> #define mpr make_pair #define ln '\n' void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);} #define int long long signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector <int> g[n]; for ( int i = 1; i <= n; i++ ){ int x, y; cin >> x >> y; g[--x].pb(--y); g[y].pb(x); } map <int,int> mp; auto djkstra = [&](int x){ vector <int> dis(n, -1), dp(n); dis[x] = 0; dp[x] = 1; queue <int> q; q.push(x); while ( !q.empty() ){ int cur = q.front(); q.pop(); for ( auto to: g[cur] ){ if ( dis[to] != -1 ){ if ( dis[to] == dis[cur]+1 ) dp[to] += dp[cur]; } else{ dis[to] = dis[cur]+1; dp[to] = dp[cur]; q.push(to); } } } for ( int i = 0; i < n; i++ ) mp[dis[i]] += dp[i]; }; for ( int i = 0; i < n; i++ ){ djkstra(i); } int cnt = mp.rbegin()->second; cout << cnt/2; cout << '\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 316 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 316 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 316 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 2 ms | 316 KB | Output is correct |
14 | Correct | 10 ms | 324 KB | Output is correct |
15 | Correct | 13 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 464 KB | Output is correct |
2 | Correct | 12 ms | 400 KB | Output is correct |
3 | Correct | 38 ms | 392 KB | Output is correct |
4 | Correct | 44 ms | 384 KB | Output is correct |
5 | Correct | 949 ms | 720 KB | Output is correct |
6 | Correct | 411 ms | 784 KB | Output is correct |
7 | Correct | 1002 ms | 788 KB | Output is correct |
8 | Correct | 846 ms | 904 KB | Output is correct |
9 | Correct | 939 ms | 728 KB | Output is correct |
10 | Correct | 1370 ms | 740 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1567 ms | 9392 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |