Submission #106178

#TimeUsernameProblemLanguageResultExecution timeMemory
106178dupreezBosses (BOI16_bosses)C++14
0 / 100
3 ms512 KiB
#include <iostream> #include <algorithm> #include <cstring> #include <sstream> #include <map> #include <queue> #include <vector> #include <stack> #include <unordered_map> #include <climits> #define mk make_pair #define pb push_back #define scanf scanf_s using namespace std; typedef long long int ll; typedef short int ui; typedef unsigned long long int ull; const int N = 5010; int n; ll ans; vector<int> g[N]; int main() { cin >> n; ans = LONG_MAX; for (int i = 1; i <= n; i++) { int v1; cin >> v1; while (v1--) { int v2; cin >> v2; g[v2].pb(i); } } for (int i = 1; i <= n; i++) { ll cv = 0,dpt[N]; memset(dpt, -1, sizeof(dpt)); dpt[i] = 1; queue<int> q; q.push(i); while (!q.empty()) { int ci = q.front(); q.pop(); cv += dpt[ci]; for (int i = 0; i < g[ci].size(); i++) { int ni = g[ci][i]; if (dpt[ni] != -1)continue; dpt[ni] = dpt[ci] + 1; q.push(ni); } } ans = min(ans, cv); } cout << ans << endl; return 0; }

Compilation message (stderr)

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