제출 #1091904

#제출 시각아이디문제언어결과실행 시간메모리
1091904vjudge1Bosses (BOI16_bosses)C++17
0 / 100
0 ms348 KiB
// Meow :3 #include <bits/stdc++.h> #define int long long int using namespace std; const int MAXN = 1e3 + 5; queue <int> q; bool mark[MAXN]; vector <int> adj[MAXN]; int h[MAXN]; int ans = 0; void bfs(){ while(!q.empty()){ int v = q.front(); q.pop(); ans += h[v]; for(auto u : adj[v]){ if(!mark[u]){ h[u] = h[v] + 1; mark[u] = true; q.push(u); } } } } signed main(){ int n; cin>>n; for(int i = 1 ; i <= n ; i++){ int k; cin>>k; for(int j = 1 ; j <= k ; j++){ int x; cin>>x; adj[x].push_back(i); } } int ANS = INT_MAX; for(int i = 1 ; i <= n ; i++){ mark[i] = 1; q.push(i); h[i] = 1; bfs(); memset(mark , 0 , sizeof mark); ANS = min(ans , ANS); } cout<<ANS<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...