제출 #546743

#제출 시각아이디문제언어결과실행 시간메모리
546743JomnoiBosses (BOI16_bosses)C++17
0 / 100
1 ms388 KiB
#include <bits/stdc++.h> #define DEBUG 0 using namespace std; const int MAX_N = 5e3 + 10; const long long INF = 1e18 + 7; long long sum; vector <int> adj[MAX_N]; bitset <MAX_N> visited; int dfs(int u) { int res = 1; for(auto v : adj[u]) { if(visited[v] == false) { visited[v] = true; res += dfs(v); } } sum += res; return res; } int main() { cin.tie(0)->sync_with_stdio(0); int n; cin >> n; for(int i = 1; i <= n; i++) { int k; cin >> k; while(k--) { int p; cin >> p; adj[p].push_back(i); } } long long ans = INF; for(int i = 1; i <= n; i++) { visited = 0; sum = 0; visited[i] = true; dfs(i); if(visited.count() == n) { ans = min(ans, sum); } } cout << ans; return 0; }

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

bosses.cpp: In function 'int main()':
bosses.cpp:45:28: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |         if(visited.count() == n) {
      |            ~~~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...