#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define ff first
#define ss second
using namespace std;
const int MAX = 5e4+5;
ll D[MAX],C[MAX],ans[MAX];
pair<int,int>dp[(1<<21)+5];
vector<int>v[MAX];
ll maxi=0;
void bfs(int x){
memset(D,-1,sizeof(D));
memset(C,0,sizeof(C));
queue<int>q;
D[x]=0; C[x] = 1; q.push(x);
while(!q.empty()){
int u=q.front();
q.pop();
for(auto it:v[u]){
if(D[it]==-1){
D[it]=D[u]+1; C[it]=C[u];
ans[D[it]]+=C[u]; q.push(it);
}
else if(D[it]==D[u]+1){
C[it]+=C[u]; ans[D[it]]+=C[u];
}
maxi=max(maxi,D[it]);
}
}
}
void go(){
int n; cin>>n;
for(int i=0;i<n;i++){
int a,b; cin>>a>>b;
v[a].push_back(b);
v[b].push_back(a);
}
for(int i=0;i<n;i++){
bfs(i+1);
}
cout<<ans[maxi]/2<<endl;
}
int main(){
fastio;
go();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2260 KB |
Output is correct |
2 |
Correct |
1 ms |
2260 KB |
Output is correct |
3 |
Correct |
2 ms |
2268 KB |
Output is correct |
4 |
Correct |
2 ms |
2260 KB |
Output is correct |
5 |
Correct |
1 ms |
2260 KB |
Output is correct |
6 |
Correct |
2 ms |
2268 KB |
Output is correct |
7 |
Correct |
2 ms |
2260 KB |
Output is correct |
8 |
Correct |
1 ms |
2260 KB |
Output is correct |
9 |
Correct |
1 ms |
2260 KB |
Output is correct |
10 |
Correct |
2 ms |
2260 KB |
Output is correct |
11 |
Correct |
2 ms |
2260 KB |
Output is correct |
12 |
Correct |
2 ms |
2260 KB |
Output is correct |
13 |
Correct |
4 ms |
2260 KB |
Output is correct |
14 |
Correct |
10 ms |
2308 KB |
Output is correct |
15 |
Correct |
10 ms |
2276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
2336 KB |
Output is correct |
2 |
Correct |
15 ms |
2328 KB |
Output is correct |
3 |
Correct |
22 ms |
2260 KB |
Output is correct |
4 |
Correct |
21 ms |
2260 KB |
Output is correct |
5 |
Correct |
347 ms |
2484 KB |
Output is correct |
6 |
Correct |
253 ms |
2520 KB |
Output is correct |
7 |
Correct |
396 ms |
2480 KB |
Output is correct |
8 |
Correct |
385 ms |
2636 KB |
Output is correct |
9 |
Correct |
349 ms |
2388 KB |
Output is correct |
10 |
Correct |
382 ms |
2480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
26 ms |
13644 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |