답안 #931602

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
931602 2024-02-22T06:45:05 Z 12345678 철인 이종 경기 (APIO18_duathlon) C++17
23 / 100
1000 ms 1048576 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int nx=1e5+5;

ll n, m, u, v, vs[nx], sz[nx], res;
vector<int> d[nx];

void dfs(int u, int p)
{
    vs[u]=1;
    ll vl=0, sm=0;
    sz[u]=1;
    for (auto v:d[u]) if (v!=p) dfs(v, u), vl+=(sz[v]), sm+=(sz[v]*sz[v]), sz[u]+=sz[v];
    res+=(vl*vl-sm)/2;
}

void dfs2(int u, int p, int rtsz)
{
    for (auto v:d[u]) if (v!=p) res+=(rtsz-sz[v])*(sz[v]-1), dfs2(v, u, rtsz);
}

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>m;
    for (int i=0; i<m; i++) cin>>u>>v, d[u].push_back(v), d[v].push_back(u);
    for (int i=1; i<=n; i++) if (!vs[i]) dfs(i, i), dfs2(i, i, sz[i]);
    cout<<2*res;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 683 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 683 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1071 ms 940600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2820 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2908 KB Output is correct
5 Correct 1 ms 2920 KB Output is correct
6 Correct 1 ms 2908 KB Output is correct
7 Correct 1 ms 2908 KB Output is correct
8 Correct 1 ms 2908 KB Output is correct
9 Correct 1 ms 2656 KB Output is correct
10 Correct 1 ms 2660 KB Output is correct
11 Correct 1 ms 2660 KB Output is correct
12 Correct 1 ms 2820 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2648 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 1 ms 2652 KB Output is correct
19 Correct 1 ms 2652 KB Output is correct
20 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 8816 KB Output is correct
2 Correct 28 ms 8784 KB Output is correct
3 Correct 29 ms 8788 KB Output is correct
4 Correct 29 ms 8796 KB Output is correct
5 Correct 37 ms 8708 KB Output is correct
6 Correct 44 ms 13916 KB Output is correct
7 Correct 33 ms 12124 KB Output is correct
8 Correct 31 ms 11108 KB Output is correct
9 Correct 32 ms 10328 KB Output is correct
10 Correct 27 ms 8796 KB Output is correct
11 Correct 27 ms 8792 KB Output is correct
12 Correct 28 ms 8800 KB Output is correct
13 Correct 28 ms 8760 KB Output is correct
14 Correct 26 ms 8544 KB Output is correct
15 Correct 22 ms 8288 KB Output is correct
16 Correct 14 ms 7268 KB Output is correct
17 Correct 20 ms 9172 KB Output is correct
18 Correct 20 ms 9052 KB Output is correct
19 Correct 21 ms 9092 KB Output is correct
20 Correct 29 ms 9052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2656 KB Output is correct
2 Correct 1 ms 2660 KB Output is correct
3 Runtime error 641 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 8792 KB Output is correct
2 Correct 29 ms 8792 KB Output is correct
3 Runtime error 675 ms 1048576 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 683 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 683 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -