제출 #981813

#제출 시각아이디문제언어결과실행 시간메모리
981813blackslexBitaro’s Party (JOI18_bitaro)C++17
컴파일 에러
0 ms0 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]; int main() { scanf("%d %d %d", &n, &m, &q); 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; for (int i = 1; i <= n; i++) { priority_queue<P> pq; pq.emplace(pii(0, i), n + 1); for (auto &e: rev[i]) { auto [x, y] = dp[e][0]; pq.emplace(pii(x + 1, y), e); ptr[e] = 1; } while (!pq.empty() && dp[i].size() <= k) { auto [x, y] = pq.top(); pq.pop(); dp[i].emplace_back(x); if (ptr[y] < dp[y].size()) { auto [cx, cy] = dp[y][ptr[y]]; ptr[y]++; pq.emplace(pii(cx + 1, cy), y); } } } vector<bool> f(n + 5); 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; } }

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

bitaro.cpp: In function 'int main()':
bitaro.cpp:24:47: error: 'k' was not declared in this scope
   24 |         while (!pq.empty() && dp[i].size() <= k) {
      |                                               ^
bitaro.cpp:27:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |             if (ptr[y] < dp[y].size()) {
      |                 ~~~~~~~^~~~~~~~~~~~~~
bitaro.cpp:39:17: error: 'k' was not declared in this scope
   39 |         if (r < k) {
      |                 ^
bitaro.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d %d %d", &n, &m, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:14:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     while (m--) scanf("%d %d", &x, &y), v[x].emplace_back(y), rev[y].emplace_back(x);
      |                 ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         scanf("%d %d", &t, &r);
      |         ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:37:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |         for (auto &e: c) scanf("%d", &e), f[e] = 1;
      |                          ~~~~~^~~~~~~~~~