Submission #560585

#TimeUsernameProblemLanguageResultExecution timeMemory
560585colossal_pepeBitaro’s Party (JOI18_bitaro)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int INF = 1e9; const int BLOCK_SZ = 450; int n, m, q; vector<vector<int>> g; vector<vector<pair<int, int>>> d; void precomp() { for (int u = 0; u < n; u++) { d[u] = {{0, u}}; for (int v : g[u]) { for (auto [x, y] : d[v]) { d.push_back({x + 1, y}); } } sort(d[u].begin(), d[u].end(), greater<>()); while (d[u].size() > BLOCK_SZ) d[u].pop_back(); } } int getAns(int t, bool is_busy[]) { int i = 0; while (i < d[t].size() and is_busy[d[t][i].second]) i++; return (i < d[t].size() ? d[t][i].first : -1); } int comptueAns(int t, bool is_busy[]) { int dp[t]; for (int u = 0; u <= t; u++) { dp[u] = -INF; for (int v : g[u]) { dp[u] = max(dp[u], dpv[v] + 1); } if (not is_busy[u]) dp[u] = max(dp[u], 0); } return max(dp[u], -1); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m >> q; g.resize(n), d.resize(n); while (m--) { int u, v; cin >> u >> v; u--, v--; g[v].push_back(u); } precomp(); vector<int> busy_ppl; bool is_busy[n] = {0}; while (q--) { int t, y; cin >> t >> y; t--; busy_ppl.resize(y); for (int &c : busy_ppl) { cin >> c; c--; is_busy[c] = 1; } cout << (y < BLOCK_SZ ? getAns(t, is_busy) : comptueAns(t, is_busy)) << '\n'; for (int &c : busy_ppl) { is_busy[c] = 0; } busy_ppl.clear(); } return 0; }

Compilation message (stderr)

bitaro.cpp: In function 'void precomp()':
bitaro.cpp:18:39: error: no matching function for call to 'std::vector<std::vector<std::pair<int, int> > >::push_back(<brace-enclosed initializer list>)'
   18 |                 d.push_back({x + 1, y});
      |                                       ^
In file included from /usr/include/c++/10/vector:67,
                 from bitaro.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::pair<int, int> >]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::vector<std::pair<int, int> >&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::pair<int, int> >]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::vector<std::pair<int, int> > >::value_type&&' {aka 'std::vector<std::pair<int, int> >&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
bitaro.cpp: In function 'int getAns(int, bool*)':
bitaro.cpp:28:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     while (i < d[t].size() and is_busy[d[t][i].second]) i++;
      |            ~~^~~~~~~~~~~~~
bitaro.cpp:29:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     return (i < d[t].size() ? d[t][i].first : -1);
      |             ~~^~~~~~~~~~~~~
bitaro.cpp: In function 'int comptueAns(int, bool*)':
bitaro.cpp:37:23: error: 'dpv' was not declared in this scope; did you mean 'dp'?
   37 |    dp[u] = max(dp[u], dpv[v] + 1);
      |                       ^~~
      |                       dp
bitaro.cpp:41:16: error: 'u' was not declared in this scope
   41 |  return max(dp[u], -1);
      |                ^