Submission #723713

#TimeUsernameProblemLanguageResultExecution timeMemory
723713MardonbekhazratovBosses (BOI16_bosses)C++17
0 / 100
0 ms212 KiB
#include<bits/stdc++.h> #define ll long long using namespace std; const int INF=1e9; vector<vector<int>>v,g; vector<bool>vis; vector<int>a; int n; void dfs(int x){ vis[x]=true; int s=0; for(int z:v[x]) if(!vis[z]) g[x].push_back(z); for(int z:g[x]){ if(!vis[z]){ dfs(z); s+=a[z];} } a[x]+=s; } int solve(int x){ g.resize(n+1); vis.assign(n+1,false); a.assign(n+1,1); dfs(x); int s=0; for(int i=1;i<=n;i++) s+=a[i]; return s; } int main(){ freopen("input.txt","r",stdin); cin>>n; v.resize(n+1); for(int i=1;i<=n;i++){ int k;cin>>k; for(int j=0;j<k;j++){ int x;cin>>x; v[x].push_back(i); } } int res=INF; for(int i=1;i<=n;i++){ res=min(res,solve(i)); } cout<<res; }

Compilation message (stderr)

bosses.cpp: In function 'int main()':
bosses.cpp:37:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |  freopen("input.txt","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...