This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
vector<int> adj[MAXN];
int mark[MAXN], ans[MAXN], in[MAXN];
int a[2 * MAXN], b[2 * MAXN];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n, m, q;
cin >> n >> m >> q;
for (int i = 0; i < m; i++) {
cin >> a[i] >> b[i];
}
int resp = -1;
vector<int> lista;
int t, k;
cin >> t >> k;
for (int i = 0; i < m; i++) {
if (a[i] > t || b[i] > t) {
continue;
}
if (a[i] == t) continue;
adj[b[i]].push_back(a[i]);
in[a[i]]++;
}
for (int i = 0; i < k; i++) {
int x;
cin >> x;
mark[x] = 1;
}
lista.push_back(t);
for (int i = 0; i < (int) lista.size(); i++) {
int cur = lista[i];
if (!mark[cur]) resp = max(resp, ans[cur]);
for (int nxt : adj[cur]) {
in[nxt]--;
if (!in[nxt]) {
lista.push_back(nxt);
ans[nxt] = ans[cur] + 1;
}
}
}
cout << resp << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |