Submission #260872

# Submission time Handle Problem Language Result Execution time Memory
260872 2020-08-11T06:27:07 Z emanIaicepsa Duathlon (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] * (n-siz[i]-1);
    }
    ans += (siz[x]-1) * (n-siz[x]);
}

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';

}
# Verdict Execution time Memory Grader output
1 Runtime error 576 ms 1048580 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 576 ms 1048580 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 1106 ms 361140 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 2688 KB Output is correct
6 Correct 3 ms 2688 KB Output is correct
7 Correct 2 ms 2688 KB Output is correct
8 Correct 2 ms 2688 KB Output is correct
9 Correct 2 ms 2688 KB Output is correct
10 Incorrect 2 ms 2688 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 62 ms 6648 KB Output is correct
2 Correct 72 ms 6648 KB Output is correct
3 Correct 64 ms 6648 KB Output is correct
4 Correct 71 ms 6780 KB Output is correct
5 Correct 75 ms 6716 KB Output is correct
6 Correct 85 ms 9976 KB Output is correct
7 Correct 78 ms 8824 KB Output is correct
8 Correct 77 ms 8312 KB Output is correct
9 Correct 85 ms 7672 KB Output is correct
10 Incorrect 64 ms 6648 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Runtime error 785 ms 1048580 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 90 ms 6648 KB Output is correct
2 Correct 76 ms 6648 KB Output is correct
3 Runtime error 844 ms 1048580 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 576 ms 1048580 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 576 ms 1048580 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -