#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--) {
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |