This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*\ In The Name Of GOD
* Beyrad :D
\*/
#include "bits/stdc++.h"
#define sz(x) ((int) (x).size())
using namespace std;
const int N = 2e5 + 5;
vector<int> g[N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int n, m, q;
cin >> n >> m >> q;
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
--u, --v;
g[u].push_back(v);
}
while (q--) {
int x, t;
cin >> x >> t, x--;
vector<int> dp(n, -1);
dp[x] = 0;
for (int i = x - 1; i >= 0; i--) {
for (int j : g[i]) {
if (dp[j] != -1)
dp[i] = max(dp[i], 1 + dp[j]);
}
}
vector<bool> mk(n);
for (int i = 0; i < t; i++) {
int y;
cin >> y, y--, mk[y] = 1;
}
int ans = -1;
for (int i = 0; i < n; i++)
if (!mk[i]) ans = max(ans, dp[i]);
cout << ans << '\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... |