Submission #1066397

#TimeUsernameProblemLanguageResultExecution timeMemory
1066397boris_7Bosses (BOI16_bosses)C++17
0 / 100
0 ms348 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; vector<vector<ll>>gp; vector<ll>vis; vector<ll> sub; ll ans = LLONG_MAX,cnt=0; void dfs(ll u){ for(ll &i:gp[u]){ if(!vis[i]){ vis[i]=1; dfs(i); sub[u]+=sub[i]; } } cnt+=sub[u]; if(vis[u]==2 && cnt>gp.size()){ ans = min(ans,cnt); } } void solve(){ ll n; cin>>n; gp = vector<vector<ll>>(n); for(ll i =0;i<n;i++){ ll x; cin>>x; while(x--){ ll v; cin>>v; gp[--v].push_back(i); } } for(ll i = 0;i<n;i++){ vis = vector<ll>(n); sub = vector<ll>(n,1); vis[i]=2; cnt = 0; dfs(i); } cout<<ans<<endl; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(nullptr); // ll t;cin>>t;while(t--) solve(); }

Compilation message (stderr)

bosses.cpp: In function 'void dfs(ll)':
bosses.cpp:20:24: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     if(vis[u]==2 && cnt>gp.size()){
      |                     ~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...