Submission #341611

#TimeUsernameProblemLanguageResultExecution timeMemory
341611ronnithBitaro’s Party (JOI18_bitaro)C++14
0 / 100
1 ms492 KiB
#include <bits/stdc++.h> #define FOR(i,a,b) for(int i = (a);i < (b);i ++) #define ROF(i,a,b) for(int i = (a);i >= (b);i --) #define trav(a, b) for(auto a : (b)) #define sz(a) int((a).size()) #define all(a) (a).begin(), (a).end() #define pb push_back #define mk make_pair #define f first #define s second using namespace std; typedef long long ll; int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n, m, q; cin >> n >> m >> q; vector<int> front[n], back[n]; FOR(i,0,m){ int x, y; cin >> x >> y; x --,y --; front[x].pb(y); back[y].pb(x); } while(q --){ int t, busy, x; cin >> t >> busy;t --; vector<int> mr(n, 0), dp(n, 0); FOR(i,0,busy){ cin >> x; x --; mr[x] = 1; } FOR(i,0,n){ if(mr[i])dp[i] = INT_MIN; trav(e, back[i]){ dp[i] = max(dp[i], dp[e] + 1); } } if(dp[t] == INT_MIN){ cout << -1 << '\n'; } else { cout << dp[t] << '\n'; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...