Submission #208113

#TimeUsernameProblemLanguageResultExecution timeMemory
208113w4123Bosses (BOI16_bosses)C++17
22 / 100
5 ms504 KiB
#include <iostream> #include <string> #include <vector> #include <queue> #include <algorithm> #include <cstring> bool used[5001]; using namespace std; int main() { int n; cin >> n; vector<int> v[5001]; for (int i = 1; i <= n; i++) { int num; cin >> num; for (int j = 1; j <= num; j++) { int tmp; cin >> tmp; v[tmp].push_back(i); } } int greatest = 0; vector<int> great_index; for (int i = 2; i <= n; i++) { if (v[i].size() > greatest) { greatest = v[i].size(); great_index.clear(); great_index.push_back(i); } else if (v[i].size() == greatest) { great_index.push_back(i); } } long long res = 999999999; for (const auto& g : great_index) { long long ans = 0; memset(used, 0, sizeof(bool) * 5000); queue<pair<int, int>> q; q.push(make_pair(1, g)); used[g] = true; while (!q.empty()) { ans += q.front().first; for (const auto& c : v[q.front().second]) { if (!used[c]) { q.push(make_pair(q.front().first + 1, c)); used[c] = true; } } q.pop(); } if (ans < res) res = ans; } cout << res; }

Compilation message (stderr)

bosses.cpp: In function 'int main()':
bosses.cpp:29:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (v[i].size() > greatest)
             ~~~~~~~~~~~~^~~~~~~~~~
bosses.cpp:35:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         else if (v[i].size() == greatest)
                  ~~~~~~~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...