Submission #567510

#TimeUsernameProblemLanguageResultExecution timeMemory
567510RifalBitaro’s Party (JOI18_bitaro)C++14
14 / 100
2048 ms6604 KiB
#include <bits/stdc++.h> #include <fstream> #define endl '\n' #define mod 1668223877717 #define INF -100000000000000000 //#define ll long long //#define cin fin //#define cout fout using namespace std; //ofstream fout("convention.out"); //ifstream fin("convention.in"); const int M = 1e5 + 5; vector<int> v[M]; long long dist[M]; int main() { ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); int n, m, q; cin >> n >> m >> q; for(int i = 0; i < m; i++) { int a, b; cin >> a >> b; v[b].push_back(a); } while(q--) { int t, y; cin >> t >> y; for(int i = 0; i < y; i++) { int a; cin >> a; dist[a] = INF; } for(int i = 1; i <= n; i++) { for(auto j : v[i]) { if(dist[j] != INF) dist[i] = max(dist[i],dist[j]+1); } } if(dist[t] == INF) cout << -1 << endl; else cout << dist[t] << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...