Submission #771318

#TimeUsernameProblemLanguageResultExecution timeMemory
771318peraBosses (BOI16_bosses)C++17
0 / 100
3 ms6484 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 2e5 + 1; int n , ans , c , s; vector<int> g[N] , v(N); void dfs(int u , int x = 1){ v[u] = 1; c += x ++; ++ s; for(int i = 0;i < g[u].size();i ++){ if(!v[g[u][i]]){ dfs(g[u][i] , x); } } } main(){ ios::sync_with_stdio(0); cin.tie(0),cout.tie(0); cin >> n; for(int i = 1;i <= n;i ++){ int k;cin >> k; for(int j = 1;j <= k;j ++){ int v;cin >> v; g[v].push_back(i); } } ans = 1e14; for(int boss = 1;boss <= n;boss ++){ v = vector<int>(n + 1); c = s = 0; dfs(boss); if(s == n) ans = min(ans , c); } cout << ans << endl; }

Compilation message (stderr)

bosses.cpp: In function 'void dfs(long long int, long long int)':
bosses.cpp:15:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i = 0;i < g[u].size();i ++){
      |                ~~^~~~~~~~~~~~~
bosses.cpp: At global scope:
bosses.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...