답안 #250938

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
250938 2020-07-19T14:04:51 Z dolphingarlic 철인 이종 경기 (APIO18_duathlon) C++14
0 / 100
109 ms 21620 KB
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;

int n, m;
vector<int> graph[100001], bcc_graph[200001], stck;
int low[100001], tin[100001], timer = 1, bccs = 1, aps[100001];
ll ans;

void dfs(int node = 1, int parent = 0) {
    low[node] = tin[node] = timer++;
    stck.push_back(node);
    for (int i : graph[node]) if (i != parent) {
        if (tin[i]) low[node] = min(low[node], tin[i]);
        else {
            dfs(i, node);
            low[node] = min(low[node], low[i]);
            if (low[i] >= tin[node]) {
                bcc_graph[node].push_back(n + bccs);
                while (!bcc_graph[n + bccs].size() || bcc_graph[n + bccs].back() != i) {
                    bcc_graph[n + bccs].push_back(stck.back());
                    stck.pop_back();
                }
                bccs++;
            }
        }
    }
}

void dfs2(int node = 1, int parent = 0) {
    aps[node] = (node <= n);
    for (int i : bcc_graph[node]) {
        dfs2(i, node);
        aps[node] += aps[i];
        if (node > n) ans -= (bcc_graph[node].size() - (parent == 0)) * aps[i] * (aps[i] - 1);
    }
    if (node > n) ans -= bcc_graph[node].size() * (n - aps[node]) * (n - aps[node] - 1);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    while (m--) {
        int u, v;
        cin >> u >> v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    dfs();
    // FOR(i, 1, n + bccs) {
    //     cout << i << ": ";
    //     for (int j : bcc_graph[i]) cout << j << ' ';
    //     cout << '\n';
    // }
    ans = n * (n - 1) * (n - 2);
    dfs2();
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 7424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 7424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 85 ms 21620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 7584 KB Output is correct
2 Correct 5 ms 7552 KB Output is correct
3 Correct 6 ms 7552 KB Output is correct
4 Correct 5 ms 7680 KB Output is correct
5 Correct 5 ms 7552 KB Output is correct
6 Correct 5 ms 7552 KB Output is correct
7 Correct 5 ms 7552 KB Output is correct
8 Correct 5 ms 7608 KB Output is correct
9 Correct 5 ms 7552 KB Output is correct
10 Incorrect 6 ms 7424 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 97 ms 17800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 7552 KB Output is correct
2 Correct 5 ms 7552 KB Output is correct
3 Correct 7 ms 7552 KB Output is correct
4 Correct 7 ms 7424 KB Output is correct
5 Correct 6 ms 7424 KB Output is correct
6 Correct 7 ms 7424 KB Output is correct
7 Correct 6 ms 7424 KB Output is correct
8 Correct 5 ms 7424 KB Output is correct
9 Correct 5 ms 7424 KB Output is correct
10 Correct 5 ms 7424 KB Output is correct
11 Correct 5 ms 7424 KB Output is correct
12 Correct 6 ms 7552 KB Output is correct
13 Correct 6 ms 7528 KB Output is correct
14 Correct 6 ms 7552 KB Output is correct
15 Correct 6 ms 7552 KB Output is correct
16 Incorrect 5 ms 7424 KB Output isn't correct
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 109 ms 17832 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 7424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 7424 KB Output isn't correct
2 Halted 0 ms 0 KB -