Submission #894388

#TimeUsernameProblemLanguageResultExecution timeMemory
894388Trisanu_DasKeys (IOI21_keys)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; struct dsu { int n; vector<int> par; dsu(int _n): n(_n), par(_n) { iota(par.begin() par.end(), 0); } int leader(int x) { return par[x] == x ? x : par[x] = leader(par[x]); } }; vector<int> find_reachable(vector<int> r, vector<int> U, vector<int> V, vector<int> C) { int n = r.size(), m = U.size(); vector<vector<pair<int, int> > > adj(n); for (int i = 0; i < m; ++i) { adj[U[i]].emplace_back(V[i], C[i]); ajd[V[i]].emplace_back(U[i], C[i]); } dsu d(n); auto num = numeric_limits<size_t>::max(); vector<int> ans, solved(n); while (true) { vector nodes(n, vector<int>()); vector<int> vis(n), changed, appear(n), res; auto BFS = [&] (int S) { for (int x: res) appear[r[x]] = 0; for (int x: changed) nodes[x].clear(); res.clear(), changed.clear(); queue<int> Q; Q.push(S); while (!empty(Q)) { const auto u = Q.front(); Q.pop(); if (S != d.leader(u)) { vis[d.leader(u)] = 1; d.p[S] = d.leader(u); return; } if (vis[u]) continue; vis[u] = 1, res.push_back(u); if (!appear[r[u]]) { appear[r[u]] = 1; for (int v: nodes[r[u]]) Q.push(v); } for (auto [v, c]: e[u]) if (appear[c]) Q.push(v); else nodes[c].push_back(v), changed.push_back(c); } solved[S] = 1; if (size(res) < num) num = size(ans = res); else if (size(res) == num) for (int x: res) ans.push_back(x); }; bool hav = 0; for (int i = 0; i < n; ++i) if (d.leader(i) == i && !vis[i] && !solved[i]) hav = 1, BFS(i); if (!hav) break; } vector<int> ans_(n); for (int x: ans) ans_[x] = 1; return ans_; }

Compilation message (stderr)

keys.cpp: In constructor 'dsu::dsu(int)':
keys.cpp:8:19: error: expected ')' before 'par'
    8 |   iota(par.begin() par.end(), 0);
      |       ~           ^~~~
      |                   )
keys.cpp:8:32: error: no matching function for call to 'iota(std::vector<int>::iterator, int)'
    8 |   iota(par.begin() par.end(), 0);
      |                                ^
In file included from /usr/include/c++/10/numeric:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:84,
                 from keys.cpp:1:
/usr/include/c++/10/bits/stl_numeric.h:88:5: note: candidate: 'template<class _ForwardIterator, class _Tp> void std::iota(_ForwardIterator, _ForwardIterator, _Tp)'
   88 |     iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
      |     ^~~~
/usr/include/c++/10/bits/stl_numeric.h:88:5: note:   template argument deduction/substitution failed:
keys.cpp:8:32: note:   deduced conflicting types for parameter '_ForwardIterator' ('__gnu_cxx::__normal_iterator<int*, std::vector<int> >' and 'int')
    8 |   iota(par.begin() par.end(), 0);
      |                                ^
keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:20:3: error: 'ajd' was not declared in this scope; did you mean 'adj'?
   20 |   ajd[V[i]].emplace_back(U[i], C[i]);
      |   ^~~
      |   adj
keys.cpp: In lambda function:
keys.cpp:39:8: error: 'struct dsu' has no member named 'p'
   39 |      d.p[S] = d.leader(u);
      |        ^
keys.cpp:48:23: error: 'e' was not declared in this scope
   48 |     for (auto [v, c]: e[u])
      |                       ^