Submission #22951

#TimeUsernameProblemLanguageResultExecution timeMemory
22951BruteforcemanBosses (BOI16_bosses)C++11
0 / 100
0 ms2176 KiB
#include <bits/stdc++.h> using namespace std; vector <int> g[5555]; bool vis[5555]; int sub[5555]; int n; void dfs(int x) { vis[x] = true; sub[x] = 1; for(auto i : g[x]) { if(vis[i] == true) continue; dfs(i); sub[x] += sub[i]; } } int func(int root) { for(int i = 1; i <= n; i++) { vis[i] = false; } dfs(root); int ans = 0; for(int i = 1; i <= n; i++) { ans += sub[i]; if(vis[i] == false) return INT_MAX; } return ans; } int main() { scanf("%d", &n); for(int i = 1; i <= n; i++) { int deg; scanf("%d", &deg); for(int j = 1; j <= deg; j++) { int x; scanf("%d", &x); g[x].push_back(i); } } int ans = INT_MAX; for(int i = 1; i <= n; i++) { ans = min(ans, func(i)); } printf("%d\n", ans); return 0; }

Compilation message (stderr)

bosses.cpp: In function 'int main()':
bosses.cpp:32:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
bosses.cpp:35:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &deg);
                          ^
bosses.cpp:38:28: 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...