Submission #47804

#TimeUsernameProblemLanguageResultExecution timeMemory
47804qoo2p5Bitaro’s Party (JOI18_bitaro)C++17
14 / 100
2087 ms9148 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = (int) 1e9 + 1e6 + 123; const ll LINF = (ll) 1e18 + 1e9 + 123; #define rep(i, s, t) for (auto i = (s); i < (t); ++(i)) #define per(i, s, t) for (auto i = (s); i >= (t); --(i)) #define sz(x) ((int)(x).size()) #define all(x) (x).begin(), (x).end() #define mp make_pair #define pb push_back bool mini(auto &x, const auto &y) { if (y < x) { x = y; return 1; } return 0; } bool maxi(auto &x, const auto &y) { if (y > x) { x = y; return 1; } return 0; } void run(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); run(); return 0; } const int N = (int) 1e5 + 123; const int K = 0; int n, m, q; vector<int> g[N]; int ans[N]; int t[N], y[N]; vector<int> c[N]; int dp[N]; int naive(int id) { fill(dp, dp + N, 0); for (int v : c[id]) { dp[v] = -INF; } rep(i, 1, n + 1) { for (int j : g[i]) { if (dp[j] != -INF) { maxi(dp[i], dp[j] + 1); } } } return (dp[t[id]] == -INF ? -1 : dp[t[id]]); } int small(int id) { return -1; } void run() { cin >> n >> m >> q; rep(i, 0, m) { int u, v; cin >> u >> v; g[v].pb(u); } rep(i, 0, q) { cin >> t[i] >> y[i]; c[i].resize(y[i]); rep(j, 0, y[i]) { cin >> c[i][j]; } if (y[i] >= K) { ans[i] = naive(i); } else { ans[i] = small(i); } } rep(i, 0, q) { cout << ans[i] << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...