제출 #1331547

#제출 시각아이디문제언어결과실행 시간메모리
1331547ThanhsThe Ties That Guide Us (CEOI23_incursion)C++20
컴파일 에러
0 ms0 KiB
#include "incursion.h"
#include <bits/stdc++.h>
using namespace std;

#define name "TENBAI"
#define fi first
#define se second
#define int long long
#define endl '\n'
#define setmin(x, y) x = min((x), (y))
#define setmax(x, y) x = max((x), (y))
#define sqr(x) ((x) * (x))
#define all(x) x.begin(), x.end()

mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count());
int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);}

int n;
vector<int> g[NM], ans;

int dfs(int u, int p = -1)
{
    int sz = 1, mx = 0;
    for (int v : g[u])
        if (u != p)
        {
            auto t = dfs(v, u);
            setmax(mx, t);
        }
    ans[u] = n - sz <= mx;
    return sz;
}

vector<int> mark(vector<pair<int, int>> F, int safe)
{
    n = F.size() + 1;
    for (auto t : F)
        g[t.fi].push_back(t.se), g[t.se].push_back(t.fi);
    ans.resize(n);
    dfs(safe);
    return ans;
}

int sz[NM], dep[NM];

int dfs_sz(int u, int p = -1)
{
    sz[u] = 1;
    for (int v : g[u])
        if (v != p)
        {
            dep[v] = dep[u] + 1;
            sz[u] += dfs_sz(v, u);
        }
    return sz[u];
}

int SZ(int u, int v)
{
    return dep[u] < dep[v] ? sz[v] : n - sz[u];
}

void locate(vector<pair<int, int>> F, int curr, int t)
{
    n = F.size() + 1;
    for (auto t : F)
        g[t.fi].push_back(t.se), g[t.se].push_back(t.fi);
    dfs_sz(0);
    for (int i = 0; i < n; i++)
        sort(all(g[i]), [&](int x, int y){return SZ(i, x) < SZ(i, y);});
    while (1)
    {
        vis[curr] = 1;
        if (g[curr].empty())
            break;
        if (t == 1)
            t = visit(curr = g[curr].back());
        else
        {
            bool siu = 0;
            for (int x : g[curr])
                if (x > g[curr][0] && !vis[x])
                    t = visit(curr = x), siu = 1;
            if (!siu)
                break;
        }
    }
}

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

incursion.cpp:19:15: error: 'NM' was not declared in this scope
   19 | vector<int> g[NM], ans;
      |               ^~
incursion.cpp: In function 'long long int dfs(long long int, long long int)':
incursion.cpp:24:18: error: 'g' was not declared in this scope
   24 |     for (int v : g[u])
      |                  ^
incursion.cpp: In function 'std::vector<long long int> mark(std::vector<std::pair<long long int, long long int> >, long long int)':
incursion.cpp:38:9: error: 'g' was not declared in this scope
   38 |         g[t.fi].push_back(t.se), g[t.se].push_back(t.fi);
      |         ^
incursion.cpp: At global scope:
incursion.cpp:44:8: error: 'NM' was not declared in this scope
   44 | int sz[NM], dep[NM];
      |        ^~
incursion.cpp:44:17: error: 'NM' was not declared in this scope
   44 | int sz[NM], dep[NM];
      |                 ^~
incursion.cpp: In function 'long long int dfs_sz(long long int, long long int)':
incursion.cpp:48:5: error: 'sz' was not declared in this scope; did you mean 'se'?
   48 |     sz[u] = 1;
      |     ^~
      |     se
incursion.cpp:49:18: error: 'g' was not declared in this scope
   49 |     for (int v : g[u])
      |                  ^
incursion.cpp:52:13: error: 'dep' was not declared in this scope; did you mean 'dup'?
   52 |             dep[v] = dep[u] + 1;
      |             ^~~
      |             dup
incursion.cpp: In function 'long long int SZ(long long int, long long int)':
incursion.cpp:60:12: error: 'dep' was not declared in this scope; did you mean 'dup'?
   60 |     return dep[u] < dep[v] ? sz[v] : n - sz[u];
      |            ^~~
      |            dup
incursion.cpp:60:30: error: 'sz' was not declared in this scope; did you mean 'SZ'?
   60 |     return dep[u] < dep[v] ? sz[v] : n - sz[u];
      |                              ^~
      |                              SZ
incursion.cpp: In function 'void locate(std::vector<std::pair<long long int, long long int> >, long long int, long long int)':
incursion.cpp:67:9: error: 'g' was not declared in this scope
   67 |         g[t.fi].push_back(t.se), g[t.se].push_back(t.fi);
      |         ^
incursion.cpp:70:18: error: 'g' was not declared in this scope
   70 |         sort(all(g[i]), [&](int x, int y){return SZ(i, x) < SZ(i, y);});
      |                  ^
incursion.cpp:13:16: note: in definition of macro 'all'
   13 | #define all(x) x.begin(), x.end()
      |                ^
incursion.cpp:73:9: error: 'vis' was not declared in this scope
   73 |         vis[curr] = 1;
      |         ^~~
incursion.cpp:74:13: error: 'g' was not declared in this scope
   74 |         if (g[curr].empty())
      |             ^
incursion.cpp:77:30: error: 'g' was not declared in this scope
   77 |             t = visit(curr = g[curr].back());
      |                              ^
incursion.cpp:81:26: error: 'g' was not declared in this scope
   81 |             for (int x : g[curr])
      |                          ^