Submission #982550

#TimeUsernameProblemLanguageResultExecution timeMemory
982550blackslexBitaro’s Party (JOI18_bitaro)C++17
0 / 100
3 ms7516 KiB
#include<bits/stdc++.h> using namespace std; using pii = pair<int, int>; using P = pair<pii, int>; const int N = 1e5 + 5, K = 320; int n, m, q, x, y, t, r, ptr[N], cdp[N]; vector<int> v[N], rev[N]; vector<pii> dp[N]; bool f[N], f2[N]; int main() { scanf("%d %d %d", &n, &m, &q); int k = K; while (m--) scanf("%d %d", &x, &y), v[x].emplace_back(y), rev[y].emplace_back(x); for (int i = 1; i <= n; i++) cdp[i] = -1e9; auto mg = [&] (vector<pii> a, vector<pii> b) { vector<pii> res; for (int p1 = 0, p2 = 0; res.size() <= k && (p1 < a.size() || p2 < b.size());) { if (p1 >= b.size() || (p1 < a.size() && a[p1] > b[p2])) { res.emplace_back(a[p1]); f2[a[p1++].second] = 1; } else { res.emplace_back(b[p2]); f2[b[p2++].second] = 1; } while (p1 < a.size() && f2[a[p1].second]) p1++; while (p2 < b.size() && f2[b[p2].second]) p2++; } for (auto &[x, y]: res) f2[y] = 0; return res; }; for (int i = 1; i <= n; i++) { dp[i] = {{-1, i}, {-1e9, n + 1}}; for (auto &e: rev[i]) dp[i] = mg(dp[i], dp[e]); for (auto &[x, y]: dp[i]) x++; } while (q--) { scanf("%d %d", &t, &r); vector<int> c(r); for (auto &e: c) scanf("%d", &e), f[e] = 1; int ans = -1; if (r < k) { for (auto &[x, y]: dp[t]) if (!f[y]) {ans = x; break;} } else { cdp[t] = 0; for (int i = t; i >= 1; i--) { for (auto &e: v[i]) cdp[i] = max(cdp[i], cdp[e] + 1); if (!f[i]) ans = max(ans, cdp[i]); } for (int i = t; i >= 1; i--) cdp[i] = -1e9; } printf("%d\n", ans); for (auto &e: c) f[e] = 0; } }

Compilation message (stderr)

bitaro.cpp: In lambda function:
bitaro.cpp:20:45: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |         for (int p1 = 0, p2 = 0; res.size() <= k && (p1 < a.size() || p2 < b.size());) {
      |                                  ~~~~~~~~~~~^~~~
bitaro.cpp:20:57: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         for (int p1 = 0, p2 = 0; res.size() <= k && (p1 < a.size() || p2 < b.size());) {
      |                                                      ~~~^~~~~~~~~~
bitaro.cpp:20:74: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         for (int p1 = 0, p2 = 0; res.size() <= k && (p1 < a.size() || p2 < b.size());) {
      |                                                                       ~~~^~~~~~~~~~
bitaro.cpp:21:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |             if (p1 >= b.size() || (p1 < a.size() && a[p1] > b[p2])) {
      |                 ~~~^~~~~~~~~~~
bitaro.cpp:21:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |             if (p1 >= b.size() || (p1 < a.size() && a[p1] > b[p2])) {
      |                                    ~~~^~~~~~~~~~
bitaro.cpp:28:23: 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 (p1 < a.size() && f2[a[p1].second]) p1++;
      |                    ~~~^~~~~~~~~~
bitaro.cpp:29:23: 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 |             while (p2 < b.size() && f2[b[p2].second]) p2++;
      |                    ~~~^~~~~~~~~~
bitaro.cpp: In function 'int main()':
bitaro.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d %d %d", &n, &m, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:16:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     while (m--) scanf("%d %d", &x, &y), v[x].emplace_back(y), rev[y].emplace_back(x);
      |                 ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         scanf("%d %d", &t, &r);
      |         ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:42:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |         for (auto &e: c) scanf("%d", &e), f[e] = 1;
      |                          ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...