Submission #790729

#TimeUsernameProblemLanguageResultExecution timeMemory
790729christinelynnBosses (BOI16_bosses)C++17
0 / 100
5 ms9696 KiB
#include<bits/stdc++.h> #define pb push_back #define int long long #define INF 1e18 #define endl '\n' using namespace std; int n , k , ans = 1e18 , ttl = 0; vector < int > adj[200005]; vector < int > tree[200005]; bool vis[200005]; int dfs(int cur){ int tt = 1; for(int u : tree[cur]){ tt += dfs(u); } ttl += tt; return tt; } void bfs(int s){ queue < int > q; vis[s] = true; q.push(s); while(!q.empty()){ int u = q.front(); q.pop(); for(int i : adj[u]){ if(!vis[i]){ vis[i] = true; q.push(i); tree[u].pb(i); } } } ttl = 0; int tmp = dfs(s); //cout << s << " " << ttl << endl; ans = min(ans , ttl); } signed main(){ cin >> n; for(int i = 1 ; i <= n ; i++){ cin >> k; for(int j = 1 ; j <= k ; j++){ int tmp; cin >> tmp; adj[tmp].pb(i); } } for(int i = 1 ; i <= n ; i++){ for(int j = 1 ; j <= n ; j++){ vis[j] = false; tree[j].clear(); } bfs(i); } cout << ans << endl; }

Compilation message (stderr)

bosses.cpp: In function 'void bfs(long long int)':
bosses.cpp:39:7: warning: unused variable 'tmp' [-Wunused-variable]
   39 |   int tmp = dfs(s);
      |       ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...