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;
void maxi(int &x, int y) {
if(x < y) x = y;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
const int C = 1005;
int n, m, q;
cin >> n >> m >> q;
vector<vector<int>> g(n+1);
vector<vector<int>> r(n+1);
for(int i = 1; i <= m; ++i) {
int u, v; cin >> u >> v;
g[u].push_back(v);
r[v].push_back(u);
}
vector<bool> blocked(n+1);
while(q--) {
int t, x; cin >> t >> x;
vector<int> v(x);
for(int i = 0; i < x; ++i) {
cin >> v[i];
blocked[v[i]] = 1;
}
vector<int> dp(n+1, -1e6);
for(int i = 1; i <= t; ++i) {
if(!blocked[i]) {
dp[i] = 0;
}
for(int x : r[i]) {
maxi(dp[i], dp[x]+1);
}
}
if(dp[t] < 0) {
dp[t] = -1;
}
cout << dp[t] << '\n';
for(int i : v) blocked[i] = 0;
}
}
Compilation message (stderr)
bitaro.cpp: In function 'int main()':
bitaro.cpp:8:12: warning: unused variable 'C' [-Wunused-variable]
8 | const int C = 1005;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |