답안 #736109

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
736109 2023-05-05T08:35:29 Z becaido 낙하산 고리들 (IOI12_rings) C++17
컴파일 오류
0 ms 0 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include <bits/stdc++.h>
using namespace std;
 
#ifdef WAIMAI
#define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE)
void dout() {cout << '\n';}
template<typename T, typename...U>
void dout(T t, U...u) {cout << t << (sizeof...(u) ? ", " : ""), dout(u...);}
#else
#define debug(...) 7122
#endif
 
#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second
 
const int SIZE = 1e6 + 5;
 
int n, mxdeg;
vector<int> adj[SIZE];
 
struct DS {
    int p, cnt[5], mxD;
    int cycle, csum;
    int to[SIZE], sz[SIZE], sum[SIZE], deg[SIZE], mxdeg[SIZE];
    void init() {
        memset(cnt, 0, sizeof(cnt));
        mxD = cycle = csum = 0;
        cnt[0] = n - (p != 0);
        iota(to + 1, to + n + 1, 1);
        fill(sz + 1, sz + n + 1, 1);
        fill(sum + 1, sum + n + 1, 0);
        fill(deg + 1, deg + n + 1, 0);
        fill(mxdeg + 1, mxdeg + n + 1, 0);
    }
    void build(int P = 0) {
        p = P;
        init();
        FOR (i, 1, n) for (int j : adj[i]) if (i < j) Merge(i, j);
    }
    int dsu(int x) {
        return x == to[x] ? x : (to[x] = dsu(to[x]));
    }
    void add(int x) {
        cnt[mxdeg[x] < 4 ? mxdeg[x] : 4]++;
        if (mxdeg[x] == 2 && sum[x] == 2 * sz[x]) cycle++, csum = sz[x];
        mxD = max(mxD, mxdeg[x]);
    }
    void del(int x) {
        cnt[mxdeg[x] < 4 ? mxdeg[x] : 4]--;
        if (mxdeg[x] == 2 && sum[x] == 2 * sz[x]) cycle--;
    }
    void Merge(int a, int b) {
        if (a == p || b == p) return;
        int da = dsu(a), db = dsu(b);
        if (da == db) del(da);
        else del(da), del(db);
 
        sum[da]++, sum[db]++;
        mxdeg[da] = max(mxdeg[da], ++deg[a]);
        mxdeg[db] = max(mxdeg[db], ++deg[b]);
 
        if (da == db) {add(da);return;}
        if (sz[da] < sz[db]) swap(da, db);
        to[db] = da;
        sz[da] += sz[db];
        sum[da] += sum[db];
        mxdeg[da] = max(mxdeg[da], mxdeg[db]);
        add(da);
    }
} ori, ds[4];
 
void Init(int N) {
    n = N;
    ori.build();
}
 
void Link(int a, int b) {
    a++, b++;
    if (a > b) swap(a, b);
    adj[a].pb(b);
    adj[b].pb(a);
    ori.Merge(a, b);
    int cur = ori.mxD;
    if (cur == mxdeg + 1) {
        if (cur == 4) {
            FOR (i, 1, n) if (adj[i].size() == 4) {
                ds[0].build(i);
                break;
            }
        }
        if (cur == 3) {
            FOR (i, 1, n) if (adj[i].size() == 3) {
                ds[0].build(i);
                int k = 0;
                for (int j : adj[i]) ds[++k].build(j);
                break;
            }
        }
    }
    mxdeg = cur;
    if (mxdeg == 4) ds[0].Merge(a, b);
    else if (mxdeg == 3) FOR (i, 0, 3) ds[i].Merge(a, b);
}
 
int CountCritical() {
    if (mxdeg <= 1) return n;
    if (mxdeg == 2) return ori.cycle == 0 ? n : ori.cycle == 1 ? ori.csum : 0;
    int ans = 0;
    FOR (i, 0, (mxdeg == 3 ? 3 : 0)) ans += ds[i].mxD <= 1 || (ds[i].mxD == 2 && ds[i].cycle == 0);
    return ans;
}

Compilation message

rings.cpp:68:2: error: extended character   is not valid in an identifier
   68 |         if (da == db) {add(da);return;}
      |  ^
rings.cpp:68:5: error: extended character   is not valid in an identifier
   68 |         if (da == db) {add(da);return;}
      |    ^
rings.cpp:68:8: error: extended character   is not valid in an identifier
   68 |         if (da == db) {add(da);return;}
      |      ^
rings.cpp:68:11: error: extended character   is not valid in an identifier
   68 |         if (da == db) {add(da);return;}
      |        ^
rings.cpp:69:2: error: extended character   is not valid in an identifier
   69 |         if (sz[da] < sz[db]) swap(da, db);
      |  ^
rings.cpp:69:5: error: extended character   is not valid in an identifier
   69 |         if (sz[da] < sz[db]) swap(da, db);
      |    ^
rings.cpp:69:8: error: extended character   is not valid in an identifier
   69 |         if (sz[da] < sz[db]) swap(da, db);
      |      ^
rings.cpp:69:11: error: extended character   is not valid in an identifier
   69 |         if (sz[da] < sz[db]) swap(da, db);
      |        ^
rings.cpp: In member function 'void DS::Merge(int, int)':
rings.cpp:68:2: error: '\U000000a0' was not declared in this scope
   68 |         if (da == db) {add(da);return;}
      |  ^
rings.cpp:69:4: error: expected ';' before '\U000000a0'
   69 |         if (sz[da] < sz[db]) swap(da, db);
      |   ^~
      |   ;