Submission #1127637

#TimeUsernameProblemLanguageResultExecution timeMemory
1127637moonpayBitaro’s Party (JOI18_bitaro)C++20
14 / 100
2095 ms19272 KiB
#include <algorithm> #include <cassert> #include <iostream> #include <vector> #include <set> using namespace std; using ll = long long; using vl = vector<ll>; istream &operator>>(istream &os, vl &a) { for (auto &x: a) cin >> x; return os; } constexpr int N = 200200; constexpr int B = 200; vector<int> g[N], ig[N]; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, m, q; cin >> n >> m >> q; for (int i = 0; i < m; i++) { int s, e; cin >> s >> e; g[s].push_back(e); ig[e].push_back(s); } for (int i = 0; i < q; i++) { int t, y; cin >> t >> y; vector<int> blocked(y); std::set<int> bl; for (int j = 0; j < y; j++) { cin >> blocked[j]; bl.insert(blocked[j]); } if (true) { std::vector<int> dp(n + 1, -1); dp[t] = 0; for (int j = t; j >= 1; j--) { if (dp[j] == -1) continue; for (const auto &d: ig[j]) { dp[d] = max(dp[d], dp[j] + 1); } } int value = -1; for (int g = 1; g <= t; g++) { if (!bl.contains(g)) value = max(value, dp[g]); } std::cout << value << "\n"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...