| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1361677 | javkhlantogs | Duathlon (APIO18_duathlon) | C++20 | 1110 ms | 1114112 KiB |
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll ans=0;
vector<vector<ll>> e;
vector<ll> sz;
ll getsz(ll u,ll p){
sz[u]=1;
for(auto v:e[u]){
if(v==p) continue;
sz[u]+=getsz(v,u);
}
return sz[u];
}
void dfs(ll u,ll p){
ans+=(sz[1]-sz[u])*(sz[u]-1);
for(auto v:e[u]){
if(v==p) continue;
dfs(v,u);
}
}
int main(){
ll n,m,i,j,k,q;
cin>>n>>m;
e.resize(n+1);
sz.resize(n+1);
for(i=0 ; i<m ; i++){
cin>>j>>k;
e[j].push_back(k);
e[k].push_back(j);
}
getsz(1,1);
dfs(1,1);
cout<<ans*2<<"\n";
return 0;
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
