제출 #446744

#제출 시각아이디문제언어결과실행 시간메모리
446744prvocisloBosses (BOI16_bosses)C++17
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; const int inf = 1e9 + 5; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<vector<int> > g(n); for (int i = 0; i < n; i++) { int d; cin >> d; for (int j = 0, x; j < d; j++) { cin >> x; g[--x].push_back(i); } } int ans = inf; for (int i = 0; i < n; i++) { queue<int> q; q.push(i); vector<int> d(n, inf); d[i] = 1; while (!q.empty()) { int u = q.front(); q.pop(); for (int v : g[u]) if (d[v] == inf) d[v] = d[u]+1, q.push(v); } int sum = 0; for (int j = 0; j < n; j++) sum += d[j]; ans = min(ans, sum); } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...