제출 #1091827

#제출 시각아이디문제언어결과실행 시간메모리
1091827vjudge1Bosses (BOI16_bosses)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> #define int long long #define pb push_back using namespace std; const int maxn = 5000 + 10; int n, h[maxn]; bool mark[maxn]; vector <int> adj[maxn]; queue <int> q; int32_t main (){ ios_base::sync_with_stdio(0); cin >> n; for (int x, i = 1; i <= n; i++){ cin >> x; for (int y, j = 0; j < x; j++) cin >> y, adj[y].pb(i); } int ans = 1e17; for (int i = 1; i <= n; i++){ q.push(i), mark[i] = 1, h[i] = 1; int tmp = 0; while (q.size()){ int v = q.front(); q.pop(); tmp += h[v]; for (auto u : adj[v]){ if (!mark[u]){ h[u] = h[v] + 1; q.push(u); mark[u] = 1; } } } ans = min(ans, tmp); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...