Submission #985346

#TimeUsernameProblemLanguageResultExecution timeMemory
985346ionut2212Bosses (BOI16_bosses)C++17
0 / 100
0 ms348 KiB
#include <iostream> #include <vector> #include <queue> using namespace std; vector<vector<int > > v; int viz[10011]; /*int suma(int poz) { if(sum[poz] == 0) { if(nivel[poz].size() == 0) return 1; else return 1 + } }*/ int main() { int n; cin >> n; v.resize(n+1); for(int i = 1; i<=n; i++) { int x; cin >> x; for(int j = 1; j<=x; j++) { int y; cin >> y; v[y].push_back(i); } } int sum, minim = 1e9; for(int j = 1; j<=n; j++) { queue<int> q; q.push(j); viz[j] = 1; sum = 1; while(!q.empty()) { int nod = q.front(); for(int i = 0; i < v[nod].size(); i++) { int vecin = v[nod][i]; if(!viz[vecin]) { viz[vecin] = viz[nod] + 1; sum+=viz[vecin]; q.push(vecin); } } //cout << nod << ' '; q.pop(); } //cout <<' '<< sum << '\n'; for(int i = 1; i <= n; i++) viz[i] = 0; minim = min(minim, sum); } cout << minim; return 0; } /// smin => noduri cu cat mai multe elemente

Compilation message (stderr)

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