Submission #656092

#TimeUsernameProblemLanguageResultExecution timeMemory
656092aebovBitaro’s Party (JOI18_bitaro)C++17
14 / 100
2068 ms6360 KiB
#include<iostream> #include<vector> #include<algorithm> #include<queue> #include<set> #include<queue> #include<utility> #define F first #define S second #define pb push_back using namespace std; const int N = (int)1e5 + 5; int n , m, q, u, v, t, y, x, dp[N]; bool bad[N]; vector<int> adj[N]; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> q; for(int i = 0; i < m; i ++){ cin >> u >> v; u --, v --; adj[v].pb(u); } while( q -- ){ cin >> t >> y; for(int i = 0; i < n; i ++)dp[i] = bad[i] = 0; while(y --)cin >> x,x -- ,bad[x] = 1; for (int v = 0; v < n; v ++) { for(auto u: adj[v])dp[v] = max (dp[v], dp[u] + 1); if(dp[v] == 0 && bad[v])dp[v] = -1; } cout << dp[t-1] << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...