# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
580478 | 2022-06-21T10:22:46 Z | yutabi | Shymbulak (IZhO14_shymbulak) | C++14 | 1500 ms | 8232 KB |
#include <bits/stdc++.h> using namespace std; #define pb push_back typedef long long ll; typedef pair <ll,ll> ii; int ans; int best=-1; int n; vector <vector <int> > graph; queue <int> q; vector <int> d; vector <int> c; vector <bool> v; int main() { scanf("%d",&n); graph=vector <vector <int> > (n); for(int i=0;i<n;i++) { int a,b; scanf(" %d %d",&a,&b); a--,b--; graph[a].pb(b); graph[b].pb(a); } for(int i=0;i<n;i++) { d=vector <int> (n,-1); c=vector <int> (n,0); v=vector <bool> (n,0); d[i]=0; c[i]=1; q.push(i); while(q.size()) { int a=q.front(); q.pop(); if(v[a]==1) { continue; } v[a]=1; if(d[a]>best) { best=d[a]; ans=0; } if(d[a]==best) { ans+=c[a]; } for(int j=0;j<graph[a].size();j++) { if(v[graph[a][j]]==0) { q.push(graph[a][j]); if(d[graph[a][j]]>d[a]+1 || d[graph[a][j]]==-1) { d[graph[a][j]]=d[a]+1; c[graph[a][j]]=0;; } if(d[graph[a][j]]==d[a]+1) { c[graph[a][j]]+=c[a]; } } } } } ans/=2; printf("%d",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 296 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 288 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 8 ms | 332 KB | Output is correct |
15 | Correct | 7 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 340 KB | Output is correct |
2 | Correct | 18 ms | 340 KB | Output is correct |
3 | Correct | 30 ms | 368 KB | Output is correct |
4 | Correct | 30 ms | 340 KB | Output is correct |
5 | Correct | 784 ms | 684 KB | Output is correct |
6 | Correct | 596 ms | 724 KB | Output is correct |
7 | Correct | 809 ms | 676 KB | Output is correct |
8 | Correct | 794 ms | 696 KB | Output is correct |
9 | Correct | 826 ms | 684 KB | Output is correct |
10 | Correct | 837 ms | 680 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1592 ms | 8232 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |