제출 #655928

#제출 시각아이디문제언어결과실행 시간메모리
655928aebovBitaro’s Party (JOI18_bitaro)C++17
0 / 100
3 ms5104 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; bool bad[N]; vector<int> out[N], in[N]; queue<int> qu; void bfs(){ qu.push(t); dis[t] = 0; 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); } } } for(int v = 1; v <= n; v ++){ if(bad[v]) continue; // cout << v << " " << dis[v] << endl; if(dis[v] != 1000000000)ret = max(ret, dis[v]); for(auto u : out[v])if(dis[u] != 1000000000)ret= max(ret, 1 + dis[u]); } } 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...