Submission #1089480

#TimeUsernameProblemLanguageResultExecution timeMemory
1089480coldbr3wBitaro’s Party (JOI18_bitaro)C++17
14 / 100
2059 ms14940 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<long long, long long> #define pb push_back #define F first #define S second #define all(x) (x).begin(), (x).end() const ll N = 3e5 + 100; const ll inf = 1e18; const ll mod = 1e9 + 7; const ll block = 350; ll n,m,q; vector<ll>adj[N]; ll dp[N]; void to_thic_cau(){ cin >> n >> m >> q; for(int i = 1; i <= m;i++){ ll u,v; cin >> u >> v; adj[v].pb(u); } while(q--){ ll t, sz; cin >> t >> sz; for(int i = 1; i <= n;i++) dp[i] = 0; for(int i = 1; i <= sz;i++){ ll x; cin >> x; dp[x] = -inf; } for(int i = 1; i <= n;i++) for(auto j : adj[i]) dp[i] = max(dp[i], dp[j] + 1); cout << (dp[t] < 0 ? -1 : dp[t]) << '\n'; } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); ll tc = 1; //cin >> tc; while(tc--) to_thic_cau(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...