# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
722011 | saayan007 | Bitaro’s Party (JOI18_bitaro) | C++17 | 2097 ms | 10480 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 fr first
#define sc second
#define eb emplace_back
#define nl "\n"
#warning N, Q are same but M is different
const int N = 1e5L + 1;
int n, m, q;
vector<int> adj[N];
int dp[N];
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> q;
for(int i = 0; i < m; ++i) {
int a, b;
cin >> a >> b;
adj[a].eb(b);
}
while(q--) {
int t, y;
vector<int> c;
cin >> t >> y;
c.resize(y + 1);
c[0] = 0;
for(int i = 1; i <= y; ++i) cin >> c[i];
int ans = -1;
for(int i = t; i > 0; --i) {
while(c.back() > i) c.pop_back();
dp[i] = -1;
for(auto u : adj[i])
if(u <= t && dp[u] != -1)
dp[i] = max(dp[i], dp[u] + 1);
if(i == t) dp[i] = 0;
if(c.back() != i)
ans = max(ans, dp[i]);
}
/* for(int i = 1; i <= n; ++i) cout << (i > t ? -1 : dp[i]) << ' ';cout << nl; */
cout << ans << nl;
/* cout << 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... |