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;
template <typename T>
bool mini(T& a, T b) {
if (b < a) return a = b, true;
return false;
}
template <typename T>
bool maxi(T& a, T b) {
if (b > a) return a = b, true;
return false;
}
const int N = 1e5 + 5;
const int M = 2e5 + 5;
const int Q = 1e5 + 5;
int n, m, q;
vector<int> adj[N], radj[N];
int t, y;
int c[N];
int f[N];
bool ded[N];
void solve() {
cin >> t >> y;
for (int i = 1; i <= y; i++) {
cin >> c[i];
ded[c[i]] = 1;
}
memset(f, -1, sizeof f);
f[t] = 0;
int ans = -1;
for (int i = t; i >= 1; i--) {
if (f[i] == -1) continue;
if (!ded[i]) maxi(ans, f[i]);
for (int v : radj[i]) {
maxi(f[v], f[i] + 1);
}
}
cout << ans;
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> m >> q;
for (int i = 1; i <= m; i++) {
int s, e;
cin >> s >> e;
adj[s].push_back(e);
radj[e].push_back(s);
}
assert(q == 1);
while (q--) {
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |