# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
120723 | 2019-06-25T10:25:03 Z | _demon_ | 철인 이종 경기 (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; ll w[100009]; vector<ll>v[100009]; int done[100009]; void dfs1(int node,int p){ child[node]=1; done[node]=1; if(node!=p)w[node]=w[p]+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]; } } int a[100009]; void dfs2(int node,int p){ done[node]=1; ll sum=0; for(int i=0;i<v[node].size();i++){ int u=v[node][i]; if(w[u]>w[node]){ sum+=child[u]*(n-child[u]-1); } else{ sum+=(n-child[node])*(child[node]-1); } } a[node]=sum; 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); } for(int i=0;i<n;i++){ if(done[i]==0){ dfs1(i,i); } } memset(done,0,sizeof(done)); // for(int i=0;i<n;i++)cout<<w[i]<<" "; // cout<<endl; for(int i=0;i<n;i++){ if(done[i]==0){ dfs2(i,i); } } // for(int i=0;i<n;i++)cout<<a[i]<<" "; // cout<<endl; cout<<ans<<endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 834 ms | 1048576 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 834 ms | 1048576 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1098 ms | 250576 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 3072 KB | Output is correct |
2 | Correct | 5 ms | 3200 KB | Output is correct |
3 | Correct | 4 ms | 3072 KB | Output is correct |
4 | Correct | 5 ms | 3200 KB | Output is correct |
5 | Correct | 5 ms | 3200 KB | Output is correct |
6 | Correct | 4 ms | 3200 KB | Output is correct |
7 | Correct | 4 ms | 3200 KB | Output is correct |
8 | Correct | 5 ms | 3200 KB | Output is correct |
9 | Correct | 5 ms | 3200 KB | Output is correct |
10 | Incorrect | 5 ms | 3072 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 119 ms | 8696 KB | Output is correct |
2 | Correct | 129 ms | 8824 KB | Output is correct |
3 | Correct | 140 ms | 8824 KB | Output is correct |
4 | Correct | 156 ms | 8916 KB | Output is correct |
5 | Correct | 141 ms | 8824 KB | Output is correct |
6 | Correct | 155 ms | 11616 KB | Output is correct |
7 | Correct | 145 ms | 11000 KB | Output is correct |
8 | Correct | 166 ms | 10360 KB | Output is correct |
9 | Correct | 141 ms | 9780 KB | Output is correct |
10 | Incorrect | 132 ms | 8812 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 3072 KB | Output is correct |
2 | Correct | 5 ms | 3200 KB | Output is correct |
3 | Runtime error | 962 ms | 1048576 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 139 ms | 8824 KB | Output is correct |
2 | Correct | 130 ms | 8680 KB | Output is correct |
3 | Execution timed out | 1131 ms | 999200 KB | Time limit exceeded |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 834 ms | 1048576 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 834 ms | 1048576 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |