# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
47761 | 2018-05-07T05:12:03 Z | mirbek01 | Bitaro’s Party (JOI18_bitaro) | C++17 | 7 ms | 6264 KB |
# include <bits/stdc++.h> using namespace std; const int N = 1e5 + 2; int n, m, q, d[N], used[N], ans, vis[N], f[N], t; vector <int> g[N], gr[N]; void dfs(int v){ if(v == t) return ; vis[v] = 1; for(int to : g[v]){ if(!vis[to]){ dfs(to); } if(f[to]){ d[v] = max(d[v], d[to] + 1); f[v] = 1; } } if(!used[v] && f[v]) ans = max(ans, d[v]); } int main(){ cin >> n >> m >> q; for(int i = 0; i < m; i ++){ int u, v; scanf("%d %d", &u, &v); g[u].push_back(v); } while(q --){ int y; cin >> t >> y; vector <int> v; for(int i = 1; i <= y; i ++){ int x; scanf("%d", &x); used[x] = 1; v.push_back(x); } memset(d, 0, sizeof(d)); memset(vis, 0, sizeof(vis)); memset(f, 0, sizeof(f)); f[t] = 1; ans = -1; for(int i = 1; i <= n; i ++){ if(!vis[i]) dfs(i); } cout << ans << endl; for(int i : v) used[i] = 0; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 6264 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 6264 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 6264 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |