제출 #1116935

#제출 시각아이디문제언어결과실행 시간메모리
1116935adaawf철인 이종 경기 (APIO18_duathlon)C++17
31 / 100
77 ms31776 KiB
#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], dd[100005], da[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 fl = 0, 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++;
                while (v.back() != x) {
                    gg[v.back()].push_back(hh);
                    gg[hh].push_back(v.back());
                    v.pop_back();
                }
                gg[hh].push_back(x);
                gg[x].push_back(hh);
            }
            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];
    }
    for (int w : gg[x]) {
        long long int k;
        if (w == p) k = kk - s[x];
        else k = s[w];
        if (x > n) res -= k * (k - 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;
}

컴파일 시 표준 에러 (stderr) 메시지

count_triplets.cpp: In function 'void dfs(int, int)':
count_triplets.cpp:12:9: warning: unused variable 'fl' [-Wunused-variable]
   12 |     int fl = 0, c = 0;
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...