제출 #1040248

#제출 시각아이디문제언어결과실행 시간메모리
1040248biserailievaBosses (BOI16_bosses)C++14
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> using namespace std; int ans=INT_MAX,tmp=0,cnt=0; bool vis[5007]; vector<int> g[5007]; int dfs(int u) { vis[u]=true; cnt++; int sum=0; for(auto v:g[u]) { if(vis[v])continue; sum+=dfs(v); } tmp+=sum+1; return sum+1; } int main() { cin.tie(nullptr)->ios::sync_with_stdio(false); int n; cin>>n; for(int i=1;i<=n;i++) { int k; cin>>k; while(k--) { int a; cin>>a; g[a].emplace_back(i); } } for(int i=1;i<=n;i++) { cnt=0,tmp=0; memset(vis,false,sizeof(vis)); dfs(i); if(cnt!=n)continue; ans=min(ans,tmp); } cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...