Submission #1282529

#TimeUsernameProblemLanguageResultExecution timeMemory
1282529lmquanBosses (BOI16_bosses)C++20
100 / 100
466 ms736 KiB
#define taskname "" #include <bits/stdc++.h> using namespace std; const long long kInf = 5e18; int main() { if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<vector<int>> g(n + 1); for (int i = 1; i <= n; i++) { int k; cin >> k; for (int j = 1; j <= k; j++) { int p; cin >> p; g[p].push_back(i); } } long long result = kInf; for (int i = 1; i <= n; i++) { vector<int> d(n + 1, -1); queue<int> q; q.push(i), d[i] = 1; long long s = 1; while (!q.empty()) { int u = q.front(); q.pop(); for (int v : g[u]) { if (d[v] == -1) { d[v] = d[u] + 1, s += d[v]; q.push(v); } } } bool found = false; for (int j = 1; j <= n; j++) { if (d[j] == -1) { found = true; break; } } if (!found) { result = min(result, s); } } cout << result; return 0; }

Compilation message (stderr)

bosses.cpp: In function 'int main()':
bosses.cpp:8:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     freopen(taskname".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
bosses.cpp:9:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     freopen(taskname".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...