Submission #476723

#TimeUsernameProblemLanguageResultExecution timeMemory
476723dooompyBitaro’s Party (JOI18_bitaro)C++14
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" using namespace std; using ll = long long; const int SQRT = 350; const int maxN = 1e5; int dp[maxN + 5]; vector<int> adj[maxN + 5]; vector<pair<int, int>> root[maxN + 5]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("", "r", stdin); // freopen("", "w", stdout); int n, m, q; cin >> n >> m >> q; for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; adj[b].push_back(a); } vector<int> dist(n + 5, 0); vector<int> seen(n + 5, -1); for (int i = 1; i <= n; i++) { vector<int> temp; for (auto a : adj[i]) { for (auto b : root[a]) { int k = b.second, c = b.first; if (seen[k] != i) { seen[k] = i; dist[k] = c + 1; temp.push_back(k); } else { dist[k] = max(dist[k], c + 1); } } if (seen[a] != i) { temp.push_back(a); dist[a] = 1; seen[a] = i; } } temp.push_back(i); sort(temp.begin(), temp.end(), [&](int a, int b) { return dist[a] > dist[b]; }); int sz = min(SQRT, (int) temp.size()); for (int j = 0; j < sz; j++) { root[i].push_back(dist[temp[j]], temp[j]); } } vector<int> invalid(n + 5, 0); for (int i = 1; i <= q; i++) { int x, y; cin >> x >> y; for (int j = 0; j < y; j++) { int cur; cin >> cur; invalid[cur] = i; } if(x < SQRT) { bool found = false; for (auto a : root[x]) { if (invalid[a.second] == i) continue; found = true; cout << a.first << "\n"; break; } if (!found) { cout << -1 << "\n"; } } else { for (int j = 1; j <= n; j++) { if (invalid[j] == i) dp[j] = -1; else dp[j] = 0; for (auto a : adj[j]) { if (dp[a] >= 0) dp[j] = max(dp[j], dp[a] + 1); } } cout << dp[x] << "\n"; } } }

Compilation message (stderr)

bitaro.cpp: In function 'int main()':
bitaro.cpp:55:53: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   55 |             root[i].push_back(dist[temp[j]], temp[j]);
      |                                                     ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from bitaro.cpp:1:
/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::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:7: note:   candidate expects 1 argument, 2 provided
/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::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note:   candidate expects 1 argument, 2 provided