# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
979211 | saayan007 | Bitaro’s Party (JOI18_bitaro) | C++17 | 2012 ms | 10672 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[s].eb(e);
}
while(q--) {
bool busy[n + 1] = {};
int dp[n + 1];
rep(i, 1, n) dp[i] = -1;
int tar;
cin >> tar;
/* cout << tar << ' '; */
int y; cin >> y;
/* cout << y << ' '; */
while(y--) {
int c; cin >> c;
busy[c] = 1;
/* cout << c << ' '; */
}
/* cout << nl; */
int res = -1;
dp[tar] = 0;
repd(i, tar, 1) {
for(int j : adj[i]) {
if(j > tar) continue;
if(j == tar) dp[i] = better(dp[i], 0);
if(dp[j] == -1) continue;
dp[i] = better(dp[i], dp[j] + 1);
}
if(busy[i]) continue;
res = better(res, dp[i]);
}
cout << res << 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... |