제출 #941176

#제출 시각아이디문제언어결과실행 시간메모리
941176sapientsapiensBosses (BOI16_bosses)C++14
0 / 100
1 ms348 KiB
#include <iostream> #include <vector> #include <queue> using namespace std; int n; vector <int> followers[5005]; int main() { cin >> n; for(int i = 0; i < n; i++) { int k; cin >> k; for(int j = 0; j < k; j++) { int a; cin >> a; followers[a].push_back(i + 1); } } int mi = 2e9; for(int i = 1; i <= n; i++) { //calculate the total sum of salaries when i is the ultimate boss of the company queue <pair<int, int> > q; q.push({i, 1}); bool visited[5005] = {false}; int sum = 0; visited[1] = true; while(!q.empty()) { pair <int, int> now = q.front(); q.pop(); for(int j = 0; j < followers[now.first].size(); j++) { if(!visited[followers[now.first][j]]) { visited[followers[now.first][j]] = true; q.push({followers[now.first][j], now.second + 1}); } } sum += now.second; } mi = min(mi, sum); } cout << mi; }

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

bosses.cpp: In function 'int main()':
bosses.cpp:31:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             for(int j = 0; j < followers[now.first].size(); j++) {
      |                            ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...