제출 #279695

#제출 시각아이디문제언어결과실행 시간메모리
279695errayBosses (BOI16_bosses)C++17
100 / 100
1147 ms1224 KiB
// author: erray #include<bits/stdc++.h> using namespace std; int main () { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<vector<int>> g(n); for (int i = 0; i < n; ++i) { int k; cin >> k; for (int j = 0; j < k; ++j) { int x; cin >> x; --x; g[x].push_back(i); } } long long ans = LLONG_MAX; for (int i = 0; i < n; ++i) { vector<bool> vis(n); vector<long long> val(n, 1); queue<pair<int, int>> que; que.emplace(i, -1); vector<pair<int, int>> ord; vis[i] = true; while (!que.empty()) { int v = que.front().first; ord.push_back(que.front()); que.pop(); for (auto u : g[v]) { if (vis[u]) continue; vis[u] = true; que.emplace(u, v); } } if ((int) ord.size() != n) continue; reverse(ord.begin(), ord.end()); ord.pop_back(); bool ok = true; for (auto v : ord) { val[v.second] += val[v.first]; } ans = min(ans, accumulate(val.begin(), val.end(), 0LL)); } cout << ans << '\n'; }

컴파일 시 표준 에러 (stderr) 메시지

bosses.cpp: In function 'int main()':
bosses.cpp:44:10: warning: unused variable 'ok' [-Wunused-variable]
   44 |     bool ok = true;
      |          ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...