Submission #744453

# Submission time Handle Problem Language Result Execution time Memory
744453 2023-05-18T15:07:08 Z Abito Duathlon (APIO18_duathlon) C++14
0 / 100
1000 ms 1048576 KB
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define ep insert
#define pow pwr
#define sqrt sqrtt
#define elif else if
#define y1 YONE
#define int long long
using namespace std;
const int N=1e6+5;
int n,m,sz[N],par[N];
vector<int> adj[N];
int getsize(int node,int p){
    par[node]=p;
    sz[node]=1;
    for (auto u:adj[node]){
        if (u==p) continue;
        sz[node]+=getsize(u,node);
    }return sz[node];
}
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cin>>n>>m;
    for (int i=1;i<=m;i++){
        int x,y;
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    getsize(1,0);
    int ans=0;
    for (int i=1;i<=n;i++){
        int x=sz[i]-1;
        for (auto u:adj[i]){
            if (u==par[i]) continue;
            x-=sz[u];
            ans+=x*sz[u];
        }ans+=(n-sz[i])*(sz[i]-1);
    }
    cout<<ans*2LL<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 461 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 461 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 457964 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Correct 13 ms 23764 KB Output is correct
4 Correct 14 ms 23824 KB Output is correct
5 Correct 15 ms 23892 KB Output is correct
6 Correct 15 ms 23764 KB Output is correct
7 Correct 15 ms 23856 KB Output is correct
8 Correct 13 ms 23828 KB Output is correct
9 Correct 13 ms 23800 KB Output is correct
10 Incorrect 14 ms 23764 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 29004 KB Output is correct
2 Correct 53 ms 28996 KB Output is correct
3 Correct 57 ms 29080 KB Output is correct
4 Correct 57 ms 29172 KB Output is correct
5 Correct 69 ms 29088 KB Output is correct
6 Correct 58 ms 30928 KB Output is correct
7 Correct 62 ms 30732 KB Output is correct
8 Correct 59 ms 30196 KB Output is correct
9 Correct 55 ms 29852 KB Output is correct
10 Incorrect 63 ms 29104 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 23764 KB Output is correct
2 Correct 14 ms 23764 KB Output is correct
3 Runtime error 599 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 29132 KB Output is correct
2 Correct 52 ms 28876 KB Output is correct
3 Runtime error 718 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 461 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 461 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -