Submission #744452

# Submission time Handle Problem Language Result Execution time Memory
744452 2023-05-18T15:04:09 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*2<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 568 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 568 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 357704 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 23820 KB Output is correct
2 Correct 15 ms 23764 KB Output is correct
3 Correct 14 ms 23820 KB Output is correct
4 Correct 14 ms 23816 KB Output is correct
5 Correct 18 ms 23904 KB Output is correct
6 Correct 14 ms 23892 KB Output is correct
7 Correct 18 ms 23812 KB Output is correct
8 Correct 15 ms 23892 KB Output is correct
9 Correct 14 ms 23764 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 73 ms 30256 KB Output is correct
2 Correct 64 ms 30352 KB Output is correct
3 Correct 99 ms 30352 KB Output is correct
4 Correct 56 ms 30344 KB Output is correct
5 Correct 80 ms 30408 KB Output is correct
6 Correct 70 ms 32208 KB Output is correct
7 Correct 76 ms 31976 KB Output is correct
8 Correct 80 ms 31448 KB Output is correct
9 Correct 64 ms 31052 KB Output is correct
10 Incorrect 55 ms 30252 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 23832 KB Output is correct
2 Correct 13 ms 23780 KB Output is correct
3 Runtime error 630 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 71 ms 30356 KB Output is correct
2 Correct 69 ms 30240 KB Output is correct
3 Runtime error 786 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 568 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 568 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -