제출 #878423

#제출 시각아이디문제언어결과실행 시간메모리
878423Uladzimir_RickeyRailway (BOI17_railway)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define pii pair<int, int> #define pb push_back #define F first #define S second const ll N = 1e5 + 10, LG = 20; using namespace std; int h[N], par[N][LG], k; vector<pii> adj[N]; vector<int> del[N], ans; set<int> s[N]; void dd (int v, int p = -1) { par[v][0] = p; if (p != -1) h[v] = h[p] + 1; for (int i = 1; i < LG; i++) if (par[v][i - 1] != -1) par[v][i] = par[par[v][i - 1]][i - 1]; for (auto u: adj[v]) if (p != u.F) dd(u.F, v, u.S); } int lca (int u, int v) { if (h[u] < h[v]) swap(u, v); for (int i = LG - 1; i >= 0; i--) if (par[u][i] != -1 && h[par[u][i]] >= h[v]) u = par[u][i]; if (u == v) return u; for (int i = LG - 1; i >= 0; i--) if (par[u][i] != par[v][i]) u = par[u][i], v = par[v][i]; return par[u][0]; } void dfs (int v, int p = -1) { for (auto u: adj[v]) { if (u.F != p) { dfs(u.F, v); if (s[u.F].size() >= k) { ans.pb(u.S); } if (s[v].size() < s[u.F].size()) s[v].swap(s[u.F]); for (auto uu: s[u.F]) s[v].insert(uu); s[u.F].clear(); for (auto u: del[v]) s[v].erase(u); } } } int main() { ios::sync_with_stdio(false);cin.tie(0); int n, m; cin >> n >> m >> k; memset(par, -1, sizeof par); for (int i = 1; i < n; i++) { int u, v; cin >> u >> v; adj[u].pb({v, i}); adj[v].pb({u, i}); } dd(1); for (int i = 1; i <= m; i++) { int x; cin >> x; vector<int> d(x); for (int j = 0; j < x; j++) cin >> d[j]; for (auto u: d) s[u].insert(i); int l = lca(d[0], d[1]); for (int i = 2; i < x; i++) l = lca(l, d[i]); del[l].pb(i); } dfs(1); cout << ans.size() << '\n'; sort(ans.begin(), ans.end()); for (auto u: ans) cout << u << ' '; cout << '\n'; return 0; }

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

railway.cpp:6:7: error: 'll' does not name a type
    6 | const ll N = 1e5 + 10, LG = 20;
      |       ^~
railway.cpp:8:7: error: 'N' was not declared in this scope
    8 | int h[N], par[N][LG], k;
      |       ^
railway.cpp:8:15: error: 'N' was not declared in this scope
    8 | int h[N], par[N][LG], k;
      |               ^
railway.cpp:8:18: error: 'LG' was not declared in this scope
    8 | int h[N], par[N][LG], k;
      |                  ^~
railway.cpp:9:17: error: 'N' was not declared in this scope
    9 | vector<pii> adj[N];
      |                 ^
railway.cpp:10:17: error: 'N' was not declared in this scope
   10 | vector<int> del[N], ans;
      |                 ^
railway.cpp:11:12: error: 'N' was not declared in this scope
   11 | set<int> s[N];
      |            ^
railway.cpp: In function 'void dd(int, int)':
railway.cpp:14:3: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   14 |   par[v][0] = p;
      |   ^~~
      |   __pstl::execution::v1::par
In file included from /usr/include/c++/10/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from railway.cpp:1:
/usr/include/c++/10/pstl/execution_defs.h:111:27: note: '__pstl::execution::v1::par' declared here
  111 | constexpr parallel_policy par{};
      |                           ^~~
railway.cpp:15:16: error: 'h' was not declared in this scope
   15 |   if (p != -1) h[v] = h[p] + 1;
      |                ^
railway.cpp:16:23: error: 'LG' was not declared in this scope
   16 |   for (int i = 1; i < LG; i++)
      |                       ^~
railway.cpp:19:16: error: 'adj' was not declared in this scope
   19 |   for (auto u: adj[v])
      |                ^~~
railway.cpp: In function 'int lca(int, int)':
railway.cpp:25:7: error: 'h' was not declared in this scope
   25 |   if (h[u] < h[v]) swap(u, v);
      |       ^
railway.cpp:26:16: error: 'LG' was not declared in this scope
   26 |   for (int i = LG - 1; i >= 0; i--)
      |                ^~
railway.cpp:27:9: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   27 |     if (par[u][i] != -1 && h[par[u][i]] >= h[v])
      |         ^~~
      |         __pstl::execution::v1::par
In file included from /usr/include/c++/10/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from railway.cpp:1:
/usr/include/c++/10/pstl/execution_defs.h:111:27: note: '__pstl::execution::v1::par' declared here
  111 | constexpr parallel_policy par{};
      |                           ^~~
railway.cpp:27:28: error: 'h' was not declared in this scope
   27 |     if (par[u][i] != -1 && h[par[u][i]] >= h[v])
      |                            ^
railway.cpp:30:16: error: 'LG' was not declared in this scope
   30 |   for (int i = LG - 1; i >= 0; i--)
      |                ^~
railway.cpp:31:9: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   31 |     if (par[u][i] != par[v][i])
      |         ^~~
      |         __pstl::execution::v1::par
In file included from /usr/include/c++/10/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from railway.cpp:1:
/usr/include/c++/10/pstl/execution_defs.h:111:27: note: '__pstl::execution::v1::par' declared here
  111 | constexpr parallel_policy par{};
      |                           ^~~
railway.cpp:33:10: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   33 |   return par[u][0];
      |          ^~~
      |          __pstl::execution::v1::par
In file included from /usr/include/c++/10/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from railway.cpp:1:
/usr/include/c++/10/pstl/execution_defs.h:111:27: note: '__pstl::execution::v1::par' declared here
  111 | constexpr parallel_policy par{};
      |                           ^~~
railway.cpp: In function 'void dfs(int, int)':
railway.cpp:37:16: error: 'adj' was not declared in this scope
   37 |   for (auto u: adj[v]) {
      |                ^~~
railway.cpp:40:11: error: 's' was not declared in this scope
   40 |       if (s[u.F].size() >= k) {
      |           ^
railway.cpp:43:11: error: 's' was not declared in this scope
   43 |       if (s[v].size() < s[u.F].size()) s[v].swap(s[u.F]);
      |           ^
railway.cpp:44:21: error: 's' was not declared in this scope
   44 |       for (auto uu: s[u.F]) s[v].insert(uu);
      |                     ^
railway.cpp:45:7: error: 's' was not declared in this scope
   45 |       s[u.F].clear();
      |       ^
railway.cpp:46:20: error: 'del' was not declared in this scope
   46 |       for (auto u: del[v]) s[v].erase(u);
      |                    ^~~
railway.cpp: In function 'int main()':
railway.cpp:55:10: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'?
   55 |   memset(par, -1, sizeof par);
      |          ^~~
      |          __pstl::execution::v1::par
In file included from /usr/include/c++/10/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from railway.cpp:1:
/usr/include/c++/10/pstl/execution_defs.h:111:27: note: '__pstl::execution::v1::par' declared here
  111 | constexpr parallel_policy par{};
      |                           ^~~
railway.cpp:59:5: error: 'adj' was not declared in this scope
   59 |     adj[u].pb({v, i});
      |     ^~~
railway.cpp:69:21: error: 's' was not declared in this scope
   69 |     for (auto u: d) s[u].insert(i);
      |                     ^
railway.cpp:73:5: error: 'del' was not declared in this scope
   73 |     del[l].pb(i);
      |     ^~~