# include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 2;
int n, m, q, d[N], used[N];
vector <int> g[N];
int main(){
cin >> n >> m >> q;
for(int i = 0; i < m; i ++){
int u, v;
cin >> u >> v;
g[v].push_back(u);
}
while(q --){
int t, y;
cin >> t >> y;
vector <int> v;
for(int i = 1; i <= y; i ++){
int x;
cin >> x;
used[x] = 1;
v.push_back(x);
}
queue <int> q;
q.push(t);
memset(d, 0, sizeof(d));
while(!q.empty()){
int v = q.front();
q.pop();
for(int to : g[v]){
q.push(to);
d[to] = max(d[v] + 1, d[to]);
}
}
int ans = 0;
for(int i = 1; i <= n; i ++){
if(!used[i])
ans = max(ans, d[i]);
}
if(!ans) ans = -1;
cout << ans << endl;
for(int i : v)
used[i] = 0;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
3064 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
3064 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
3064 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |