QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#682920#8333. Giftucup-team1412#Compile Error//C++202.2kb2024-10-27 17:55:572024-10-27 17:55:58

Judging History

你现在查看的是最新测评结果

  • [2024-10-27 17:55:58]
  • 评测
  • [2024-10-27 17:55:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
const ll maxn = 1e5 + 10;
const ll maxm = 1e5 + 10;
const ll inf = 0x3f3f3f3f;
struct edge {
    ll next;
    ll to;
};
edge e[maxm << 1];
ll n, m;
ll cut[maxn];
ll head[maxn];
ll dfn[maxn];
ll low[maxn];
ll degree[maxn];
ll cnt;
ll tot;
ll cntdegree[maxn];
void add(ll u, ll v) {
    e[++cnt].to = v;
    e[cnt].next = head[u];
    head[u] = cnt;
}
bool vis[maxn];
ll from;
bool found;
bool ad;
vector<ll> ans;

void dfs(ll now, ll fa) {
    dfn[now] = ++cnt;
    for (ll i = head[now]; i; i = e[i].next) {
        ll to = e[i].to;
        if (!dfn[to]) {
            dfs(to, now);
            if (found) {
                if (ad)
                    ans.push_back(now);
                if (now == from) ad = false;
                return;
            }
        }
        else if (dfn[to] < dfn[now] && to != fa) {
            from = to;
            found = true;
            ad = true;
            ans.push_back(now);
            return;
        }  
    }
}

ll main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (ll i = 1; i <= n; i++) {
        ll u, v;
        cin >> u >> v;
        degree[u]++;
        degree[v]++;
        add(u, v);
        add(v, u);
    }
    ll cntbigger = 0;
    for (ll i = 1; i <= n; i++) {
        cntdegree[degree[i]]++;
        if (degree[i] >= 5) cntbigger++;;
    }
    dfs(1, 0);
    ll totans = 0;
    for (ll i = 0; i < ans.size(); i++) {
        ll j = (i + 1) % ans.size();
        cntdegree[degree[i]]--;
        cntdegree[degree[j]]--;
        cntdegree[degree[i] - 1]++;
        cntdegree[degree[j] - 1]++;
        if (degree[i] == 5) cntbigger--;
        if (degree[j] == 5) cntbigger--;
        if (cntbigger == 0) {
            totans += cntdegree[1] + cntdegree[2] + cntdegree[3];
        }
        cntdegree[degree[i]]++;
        cntdegree[degree[j]]++;
        cntdegree[degree[i] - 1]--;
        cntdegree[degree[j] - 1]--;
        if (degree[i] == 5) cntbigger++;
        if (degree[j] == 5) cntbigger++;
    }
    cout << totans;

    return 0;
}

Details

answer.code:56:1: error: ‘::main’ must return ‘int’
   56 | ll main() {
      | ^~