제출 #644072

#제출 시각아이디문제언어결과실행 시간메모리
644072valerikkBitaro’s Party (JOI18_bitaro)C++17
14 / 100
2086 ms141132 KiB
#include <stdio.h> #include <stdlib.h> #include <vector> #include <algorithm> using namespace std; const int MAXN = 100001; int n, m, q; vector<int> g[MAXN]; bool bad[MAXN]; int dp[MAXN]; vector<pair<int, int>> best[MAXN]; bool used[MAXN]; int main() { scanf("%d%d%d", &n, &m, &q); for (int i = 0; i < m; ++i) { int s, e; scanf("%d%d", &s, &e); --s, --e; g[s].push_back(e); } for (int v = 0; v < n; ++v) { best[v].push_back({0, v}); } for (int v = 0; v < n; ++v) { sort(best[v].rbegin(), best[v].rend()); for (auto p : best[v]) { used[p.second] = false; } vector<pair<int, int>> tmp; for (auto p : best[v]) { if (tmp.size() == 100) break; if (!used[p.second]) { tmp.push_back(p); used[p.second] = true; } } swap(best[v], tmp); for (int u : g[v]) { for (auto p : best[v]) { best[u].push_back({p.first + 1, p.second}); } } } while (q--) { int t, y; scanf("%d%d", &t, &y); --t; vector<int> c(y); for (int i = 0; i < y; ++i) { scanf("%d", &c[i]); --c[i]; } for (int i = 0; i < y; ++i) { bad[c[i]] = true; } if (y >= 100) { for (int v = 0; v < n; ++v) { dp[v] = bad[v] ? -1 : 0; } for (int v = 0; v < n; ++v) { if (dp[v] == -1) continue; for (int u : g[v]) { dp[u] = max(dp[u], dp[v] + 1); } } printf("%d\n", dp[t]); } else { int ans = -1; for (auto p : best[t]) { if (!bad[p.second]) ans = max(ans, p.first); } printf("%d\n", ans); } for (int i = 0; i < y; ++i) { bad[c[i]] = false; } } }

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

bitaro.cpp: In function 'int main()':
bitaro.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%d%d%d", &n, &m, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         scanf("%d%d", &s, &e);
      |         ~~~~~^~~~~~~~~~~~~~~~
bitaro.cpp:58:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |         scanf("%d%d", &t, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~
bitaro.cpp:63:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |             scanf("%d", &c[i]);
      |             ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...