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;
#define FOR(i, j, k, l) for(int i = (j); i < (k); i += (l))
#define FORD(i, j, k, l) for(int i = (j); i >= (k); i-=(l))
#define REP(i, n) FOR(i, 0, n, 1)
#define REPD(i, n) FORD(i, n, 0, 1)
#define pb push_back
int main(){
int n, m, q;
cin >> n >> m >> q;
vector<vector<int>> g(n);
REP(i, m){
int s, e;
cin >> s >> e;
s--; e--;
g[s].pb(e);
}
REP(i, q){
int t, y;
cin >> t >> y;
t--;
vector<int> dp(n, -(int)1e9);
vector<bool> ign(n, false);
dp[t] = 0;
REPD(v, t - 1){
for(int x : g[v]){
dp[v] = max(dp[v], dp[x] + 1);
}
}
REP(j, y){
int x;
cin >> x;
x--;
ign[x] = true;
}
int ans = 0;
REP(j, n){
if(!ign[j])
ans = max(ans, dp[j]);
}
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... |