답안 #260871

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
260871 2020-08-11T06:21:57 Z emanIaicepsa 철인 이종 경기 (APIO18_duathlon) C++14
0 / 100
1000 ms 1048580 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define vi vector<int>
#define pb emplace_back
#define fi first
#define se second
#define all(n) (n).begin(),(n).end()
#define mem(n,m) memset(n,m,sizeof(n))
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define dbg(...) cerr<<#__VA_ARGS__<<" = ";_do(__VA_ARGS__);
template<typename A> void _do(A x){cerr<<x<<'\n';}
template<typename A,typename ...B> void _do(A x,B ...y){cerr<<x<<", ";_do(y...);}

ll n,m;
vi E[100005];
ll siz[100005], ans=0;

void dfs(int x,int p){
    siz[x] = 1;
    for(auto i:E[x]){
        if(i==p) continue;
        dfs(i,x);
        siz[x] += siz[i];
    }
}

void dfs2(int x,int p){
    for(auto i:E[x]){
        if(i==p) continue;
        dfs2(i,x);
        ans += siz[i] * (siz[x]-siz[i]-1);
    }
    ans += (siz[x]-1) * (n-siz[x]) * 2;
}

signed main(){
	IOS;
    cin>>n>>m;
    for(int i=1,a,b;i<=m;i++){
        cin>>a>>b;
        E[a].pb(b);
        E[b].pb(a);
    }

    dfs(1,0);
    dfs2(1,0);

    cout<<ans<<'\n';

}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 559 ms 1048580 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 559 ms 1048580 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 1106 ms 387996 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 2 ms 2816 KB Output is correct
5 Correct 2 ms 2720 KB Output is correct
6 Correct 2 ms 2688 KB Output is correct
7 Correct 3 ms 2688 KB Output is correct
8 Correct 3 ms 2688 KB Output is correct
9 Correct 3 ms 2688 KB Output is correct
10 Incorrect 2 ms 2688 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 6648 KB Output is correct
2 Correct 74 ms 6756 KB Output is correct
3 Correct 77 ms 6672 KB Output is correct
4 Correct 75 ms 6788 KB Output is correct
5 Correct 62 ms 6648 KB Output is correct
6 Correct 78 ms 9976 KB Output is correct
7 Correct 86 ms 8824 KB Output is correct
8 Correct 80 ms 8248 KB Output is correct
9 Correct 75 ms 7672 KB Output is correct
10 Incorrect 57 ms 6648 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Runtime error 752 ms 1048580 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 6648 KB Output is correct
2 Correct 83 ms 6776 KB Output is correct
3 Runtime error 854 ms 1048576 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 559 ms 1048580 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 559 ms 1048580 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -