Submission #991764

#TimeUsernameProblemLanguageResultExecution timeMemory
991764danikoynovBitaro’s Party (JOI18_bitaro)C++14
0 / 100
1 ms2652 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } const int maxn = 1e5 + 10, block_size = sqrt(maxn); int n, m, q, sp[maxn], dp[maxn]; vector < int > adj[maxn]; void input() { cin >> n >> m >> q; for (int i = 1; i <= m; i ++) { int s, e; cin >> s >> e; adj[e].push_back(s); } } void compute() { for (int i = 1; i <= n; i ++) { dp[i] = -1e9; if (!sp[i]) dp[i] = 0; for (int u : adj[i]) dp[i] = max(dp[i], dp[u] + 1); } } void answer_queries() { for (int i = 1; i <= q; i ++) { int x, t; cin >> t >> x; vector < int > spec; for (int j = 1; j <= x; j ++) { int y; cin >> y; spec.push_back(y); sp[y] = 1; } compute(); cout << dp[t] << endl; for (int v : spec) sp[v] = 0; } } void solve() { input(); answer_queries(); } int main() { speed(); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...