Submission #1115194

#TimeUsernameProblemLanguageResultExecution timeMemory
1115194raspyBosses (BOI16_bosses)C++17
100 / 100
594 ms884 KiB
#include <bits/stdc++.h> #define int long long #define vi vector<int> #define ii pair<int, int> #define f first #define s second #define all(x) (x).begin(), (x).end() #define P 31 #define mod 1'000'000'007 #define inf 1'000'000'000'000'00 #define pb push_back #define str string #define sz size #define vvi vector<vi> #define fun function #define oopt cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false); #define file freopen("problemname.in", "r", stdin); freopen("pr.out", "w", stdout); #define dbg(v) cout << "Line(" << __LINE__ << ") -> " << #v << " = " << (v) << endl; using namespace std; template <class T, int SZ> using arr = array<T, SZ>; int ob[5005]; int cn[5005]; vi graf[5005]; void solve() { int n; cin >> n; for (int i = 0; i < n; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int p; cin >> p; graf[p-1].pb(i); } } auto bfs = [&n](int& kor) -> int { for (int i = 0; i < n; i++) ob[i] = cn[i] = 0; queue<int> q; q.push(kor); ob[kor] = cn[kor] = 1; while (q.sz()) { int t = q.front(); q.pop(); bool list = true; for (int&v:graf[t]) if (!ob[v]) { ob[v] = 1; cn[v] = cn[t]+1; q.push(v); } } int rez = 0; for (int i = 0; i < n; i++) { if (!ob[i]) return inf; rez += cn[i]; } return rez; }; int rez = inf; for (int i = 0; i < n; i++) rez = min(rez, bfs(i)); cout << rez << "\n"; } signed main() { oopt; int t = 1; // cin >> t; while (t--) solve(); return 0; }

Compilation message (stderr)

bosses.cpp: In lambda function:
bosses.cpp:54:9: warning: unused variable 'list' [-Wunused-variable]
   54 |    bool list = true;
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...