제출 #78755

#제출 시각아이디문제언어결과실행 시간메모리
78755scanhexBosses (BOI16_bosses)C++17
100 / 100
723 ms1388 KiB
#include <bits/stdc++.h> using namespace std; using nagai = long long; using ll = long long; const int N = 5000; vector<int> g[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> 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); } } int ans = 1e9; for (int rt = 0; rt < n; ++rt) { vector<int> d(n, -1); d[rt] = 1; vector<int> q = {rt}; for (int i = 0; i < q.size(); ++i) { int x = q[i]; for (int y : g[x]) { if (d[y] == -1) d[y] = d[x] + 1, q.push_back(y); } } if (count(d.begin(), d.end(), -1)) continue; ans = min(ans, accumulate(d.begin(), d.end(), 0)); } cout << ans << '\n'; return 0; }

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

bosses.cpp: In function 'int main()':
bosses.cpp:34:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < q.size(); ++i)
                   ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...