# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
120704 | 2019-06-25T09:21:04 Z | _demon_ | Duathlon (APIO18_duathlon) | C++14 | 1000 ms | 1048576 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n,m; ll child[100009]; ll ans; vector<ll>v[100009]; void dfs1(int node,int p){ child[node]=1; for(int i=0;i<v[node].size();i++){ int u=v[node][i]; if(u==p)continue; dfs1(u,node); child[node]+=child[u]; } } void dfs2(int node,int p){ ll sum=0; for(int i=0;i<v[node].size();i++){ int u=v[node][i]; if(u==p)continue; sum+=(child[u]*(n-child[u]-1))*2; } ans+=sum; for(int i=0;i<v[node].size();i++){ int u=v[node][i]; if(u==p)continue; dfs2(u,node); } } int main(){ cin>>n>>m; for(int i=0;i<m;i++){ int a,b; cin>>a>>b; a--;b--; v[a].push_back(b); v[b].push_back(a); } dfs1(0,0); dfs2(0,0); cout<<ans<<endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 946 ms | 1048576 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 946 ms | 1048576 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1089 ms | 238280 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 133 ms | 8500 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 127 ms | 8548 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 946 ms | 1048576 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 946 ms | 1048576 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |