제출 #1041880

#제출 시각아이디문제언어결과실행 시간메모리
1041880inkvizytorBosses (BOI16_bosses)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<vector<int>> g (n+1); for (int i = 1; i < n+1; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int x; cin >> x; g[x].push_back(i); } } vector<int> odw (n+1, 0); vector<int> d (n+1, 0); int score = 0, mini = 1000000000; for (int i = 1; i < n+1; i++) { odw[i] = i; d[i] = 1; score++; queue<int> q; q.push(i); while (!q.empty()) { int v = q.front(); q.pop(); for (int u : g[v]) { if (odw[u] < i) { odw[u] = i; d[u] = d[v]+1; score += d[u]; q.push(u); } } } mini = min(mini, score); } cout << mini; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...