#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ar array
#define ld long double
const int INF = 1e18 + 10;
const int N = 2e5 + 20;
const int SQRT = 400;
int n, m, q;
int dp[N];
vector<int> g[N];
void calc(int x){
memset(dp, -1, sizeof dp);
dp[x] = 0;
for(int i = x;i >= 0;i--){
for(auto u: g[i])dp[u] = max(dp[u], dp[i] + 1);
}
}
int del[N];
signed main(){ios_base::sync_with_stdio(false);cin.tie(0);
cin>>n>>m>>q;
while(m--){
int a, b;
cin>>a>>b;
--a, --b;
g[b].push_back(a);
}
memset(del, -1, sizeof del);
while(q--){
int x, y;
cin>>x>>y;
--x;
calc(x);
while(y--){
int t;
cin>>t;
--t;
del[t] = q;
}
int ans = -1;
for(int i = 0;i < n;i++){
if(del[i] != q){
ans = max(ans, dp[i]);
}
}
cout<<ans<<'\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... |