답안 #710179

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
710179 2023-03-15T05:32:23 Z vjudge1 철인 이종 경기 (APIO18_duathlon) C++17
0 / 100
1000 ms 1048576 KB
/*
Author : DeMen100ns (a.k.a Vo Khac Trieu)
School : VNU-HCM High school for the Gifted
fuck you adhoc
*/

#include <bits/stdc++.h>
#define endl '\n'

#define int long long

using namespace std;

const int N = 3e5 + 5;
const long long INF = 1e18 + 7;
const int MAXA = 1e9;
const int B = sqrt(N) + 5;

vector <int> a[N];
int sub[N]; bool f[N];
int ans = 0, n;

void dfs(int u, int par = 0){
    f[u] = true;
    //sub[u] = 1;
    for(int i : a[u]){
        if (i == par) continue;
        dfs(i, u);

        ans += sub[u] * sub[i];
        sub[u] += sub[i];
    }
    ans += (n - sub[u] - 1) * sub[u];
    sub[u]++;
}

void solve()
{
    int m; cin >> n >> m;
    for(int i = 1; i <= m; ++i){
        int u, v; cin >> u >> v;
        a[u].push_back(v);
        a[v].push_back(u);
    }

    for(int i = 1; i <= n; ++i){
        if (!f[i]) dfs(i);
    }

    cout << 2ll * ans;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    // freopen("codeforces.inp","r",stdin);
    // freopen("codeforces.out","w",stdout);

    int t = 1; // cin >> t;
    while (t--)
    {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 489 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 489 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1091 ms 518956 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7408 KB Output is correct
2 Correct 5 ms 7380 KB Output is correct
3 Correct 5 ms 7380 KB Output is correct
4 Correct 5 ms 7380 KB Output is correct
5 Correct 5 ms 7380 KB Output is correct
6 Correct 4 ms 7380 KB Output is correct
7 Correct 5 ms 7400 KB Output is correct
8 Correct 4 ms 7380 KB Output is correct
9 Correct 4 ms 7380 KB Output is correct
10 Incorrect 5 ms 7348 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 11852 KB Output is correct
2 Correct 55 ms 13240 KB Output is correct
3 Correct 42 ms 13132 KB Output is correct
4 Correct 40 ms 13108 KB Output is correct
5 Correct 46 ms 13192 KB Output is correct
6 Correct 47 ms 15928 KB Output is correct
7 Correct 72 ms 15432 KB Output is correct
8 Correct 63 ms 14804 KB Output is correct
9 Correct 62 ms 14260 KB Output is correct
10 Incorrect 53 ms 13180 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7380 KB Output is correct
2 Correct 5 ms 7380 KB Output is correct
3 Runtime error 560 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 11940 KB Output is correct
2 Correct 66 ms 13116 KB Output is correct
3 Runtime error 689 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 489 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 489 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -