# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
979573 | saayan007 | Bitaro’s Party (JOI18_bitaro) | C++17 | 2102 ms | 12628 KiB |
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 int long long
#define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
#define repd(i, a, b) for(int (i) = (a); i >= (b); --i)
#define em emplace
#define eb emplace_back
#define pi pair<int, int>
#define fr first
#define sc second
#define mp make_pair
const char nl = '\n';
const int mod = 1e9 + 7;
const int inf = 1e17;
int better(int x, int y) {
if(x == -1) return y;
return max(x, y);
}
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, m, q;
cin >> n >> m >> q;
vector<int> adj[n + 1];
rep(i, 1, m) {
int s, e;
cin >> s >> e;
adj[e].eb(s);
}
int dp[n + 1];
set<int> busy;
while(q--) {
busy.clear();
int tar;
cin >> tar;
int y; cin >> y;
rep(i, 1, y) {
int c; cin >> c;
busy.insert(c);
}
int res = -1;
rep(i, 1, tar) {
dp[i] = -1;
if(!busy.count(i)) dp[i] = 0;
for(int j : adj[i]) {
assert(j < i);
if(dp[j] == -1) continue;
dp[i] = better(dp[i], dp[j] + 1);
}
}
cout << dp[tar] << nl;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |