Submission #47761

#TimeUsernameProblemLanguageResultExecution timeMemory
47761mirbek01Bitaro’s Party (JOI18_bitaro)C++17
0 / 100
7 ms6264 KiB
# 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 (stderr)

bitaro.cpp: In function 'int main()':
bitaro.cpp:32:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d %d", &u, &v);
             ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:42:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
                   scanf("%d", &x);
                   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...