Submission #655932

#TimeUsernameProblemLanguageResultExecution timeMemory
655932aebovBitaro’s Party (JOI18_bitaro)C++17
0 / 100
5 ms7316 KiB
#include<iostream> #include<vector> #include<algorithm> #include<queue> #include<set> #include<queue> #define pb push_back using namespace std; const int N = (int)1e5 + 5; int n , m, q, u, v, t, y, x, ret = -1, dis[N], mx = 0, dp[N]; bool bad[N]; vector<int> out[N], in[N], flo[N]; queue<int> qu; void bfs(){ qu.push(t); dis[t] = 0; flo[0].pb(t); while(!qu.empty()){ int v = qu.front(); qu.pop(); for(auto u : in[v]){ if(dis[v] + 1 < dis[u]){ dis[u] = dis[v] + 1, qu.push(u); flo[dis[u]].pb(u); dp[u] = dis[u]; } } } for(int i = n; i >= 0; i --){ for(auto x : flo[i]){ for(auto y : out[x]){ if(dis[y] != 1000000000) dp[x] = max(dp[x], dp[y] + 1); } if(!bad[x])ret= max(ret, dp[x]); } } } 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; out[u].pb(v); in[v].pb(u); }fill(dis, dis + n + 2, 1000000000); while(q --){ cin >> t >> y; while(y --)cin >> x, bad[x] = 1; bfs(); cout << ret << endl; }exit(0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...