답안 #1116944

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1116944 2024-11-22T16:02:15 Z adaawf 철인 이종 경기 (APIO18_duathlon) C++17
31 / 100
69 ms 29596 KB
#include <iostream>
#include <vector>
#include <map>
using namespace std;
map<pair<int, int>, int> mm;
vector<int> g[100005], gg[200005], v;
int tin[100005], low[100005], z = 0, db[100005], hh;
long long int s[200005], f[200005], kk = 0, n, res = 0;
void dfs(int x, int p) {
    tin[x] = low[x] = ++z;
    v.push_back(x);
    int c = 0;
    for (int w : g[x]) {
        if (w == p) continue;
        if (tin[w] == 0) {
            dfs(w, x);
            low[x] = min(low[x], low[w]);
            if (low[w] >= tin[x]) {
                hh++;
                gg[hh].push_back(x);
                gg[x].push_back(hh);
                while (v.back() != x) {
                    gg[v.back()].push_back(hh);
                    gg[hh].push_back(v.back());
                    v.pop_back();
                }
            }
            c++;
        }
        else low[x] = min(low[x], tin[w]);
    }
    if (p == -1 && c >= 2) {

    }
}
void dfs3(int x, int p) {
    db[x] = 1;
    if (x <= n) kk++;
    for (int w : gg[x]) {
        if (w == p) continue;
        dfs3(w, x);
    }
}
void dfs4(int x, int p) {
    s[x] = (x <= n);
    for (int w : gg[x]) {
        if (w == p) continue;
        dfs4(w, x);
        s[x] += s[w];
        if (x > n) res -= s[w] * (s[w] - 1) * (gg[x].size() - 1);
    }
    if (x > n) res -= (kk - s[x]) * (kk - s[x] - 1) * (gg[x].size() - 1);
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    long long int m;
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    hh = n;
    for (int i = 1; i <= n; i++) {
        if (tin[i] == 0) {
            dfs(i, -1);
        }
    }
    for (int i = 1; i <= n; i++) {
        if (db[i] == 0) {
            kk = 0;
            dfs3(i, -1);
            res += kk * (kk - 1) * (kk - 2);
            dfs4(i, -1);
        }
    }
    cout << res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11600 KB Output is correct
2 Correct 3 ms 11600 KB Output is correct
3 Correct 4 ms 11600 KB Output is correct
4 Correct 3 ms 11600 KB Output is correct
5 Correct 4 ms 11600 KB Output is correct
6 Correct 3 ms 11624 KB Output is correct
7 Incorrect 3 ms 11600 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11600 KB Output is correct
2 Correct 3 ms 11600 KB Output is correct
3 Correct 4 ms 11600 KB Output is correct
4 Correct 3 ms 11600 KB Output is correct
5 Correct 4 ms 11600 KB Output is correct
6 Correct 3 ms 11624 KB Output is correct
7 Incorrect 3 ms 11600 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 46 ms 27860 KB Output is correct
2 Correct 57 ms 27840 KB Output is correct
3 Correct 53 ms 26296 KB Output is correct
4 Correct 47 ms 26260 KB Output is correct
5 Correct 42 ms 23228 KB Output is correct
6 Correct 47 ms 24912 KB Output is correct
7 Correct 58 ms 22856 KB Output is correct
8 Correct 48 ms 23368 KB Output is correct
9 Correct 54 ms 21320 KB Output is correct
10 Correct 54 ms 21796 KB Output is correct
11 Correct 42 ms 19272 KB Output is correct
12 Correct 40 ms 19272 KB Output is correct
13 Correct 42 ms 19256 KB Output is correct
14 Correct 43 ms 18952 KB Output is correct
15 Correct 28 ms 18128 KB Output is correct
16 Correct 32 ms 17756 KB Output is correct
17 Correct 5 ms 11992 KB Output is correct
18 Correct 5 ms 11992 KB Output is correct
19 Correct 7 ms 11992 KB Output is correct
20 Correct 5 ms 11992 KB Output is correct
21 Correct 5 ms 11984 KB Output is correct
22 Correct 5 ms 12088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 11600 KB Output is correct
2 Correct 3 ms 11768 KB Output is correct
3 Correct 3 ms 11600 KB Output is correct
4 Correct 3 ms 11644 KB Output is correct
5 Correct 3 ms 11600 KB Output is correct
6 Correct 3 ms 11600 KB Output is correct
7 Correct 3 ms 11600 KB Output is correct
8 Correct 3 ms 11600 KB Output is correct
9 Correct 3 ms 11600 KB Output is correct
10 Correct 3 ms 11588 KB Output is correct
11 Correct 4 ms 11600 KB Output is correct
12 Correct 3 ms 11600 KB Output is correct
13 Correct 3 ms 11600 KB Output is correct
14 Correct 3 ms 11720 KB Output is correct
15 Correct 3 ms 11600 KB Output is correct
16 Correct 3 ms 11600 KB Output is correct
17 Correct 3 ms 11768 KB Output is correct
18 Correct 3 ms 11600 KB Output is correct
19 Correct 3 ms 11600 KB Output is correct
20 Correct 3 ms 11600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 21068 KB Output is correct
2 Correct 52 ms 21128 KB Output is correct
3 Correct 61 ms 21064 KB Output is correct
4 Correct 64 ms 21068 KB Output is correct
5 Correct 69 ms 21144 KB Output is correct
6 Correct 61 ms 29596 KB Output is correct
7 Correct 53 ms 26592 KB Output is correct
8 Correct 53 ms 25160 KB Output is correct
9 Correct 52 ms 23888 KB Output is correct
10 Correct 63 ms 21216 KB Output is correct
11 Correct 54 ms 21232 KB Output is correct
12 Correct 49 ms 21148 KB Output is correct
13 Correct 59 ms 21064 KB Output is correct
14 Correct 52 ms 20640 KB Output is correct
15 Correct 42 ms 20048 KB Output is correct
16 Correct 30 ms 18000 KB Output is correct
17 Correct 38 ms 21784 KB Output is correct
18 Correct 50 ms 21608 KB Output is correct
19 Correct 38 ms 21700 KB Output is correct
20 Correct 37 ms 21836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11600 KB Output is correct
2 Correct 3 ms 11600 KB Output is correct
3 Incorrect 3 ms 11600 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 21192 KB Output is correct
2 Correct 57 ms 21076 KB Output is correct
3 Incorrect 55 ms 20448 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11600 KB Output is correct
2 Correct 3 ms 11600 KB Output is correct
3 Correct 4 ms 11600 KB Output is correct
4 Correct 3 ms 11600 KB Output is correct
5 Correct 4 ms 11600 KB Output is correct
6 Correct 3 ms 11624 KB Output is correct
7 Incorrect 3 ms 11600 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 11600 KB Output is correct
2 Correct 3 ms 11600 KB Output is correct
3 Correct 4 ms 11600 KB Output is correct
4 Correct 3 ms 11600 KB Output is correct
5 Correct 4 ms 11600 KB Output is correct
6 Correct 3 ms 11624 KB Output is correct
7 Incorrect 3 ms 11600 KB Output isn't correct
8 Halted 0 ms 0 KB -