Submission #163677

#TimeUsernameProblemLanguageResultExecution timeMemory
163677alexandra_udristoiuBosses (BOI16_bosses)C++14
0 / 100
2 ms504 KiB
#include<iostream> #include<vector> #include<cstring> #define DIM 5005 using namespace std; int n, i, j, m, x, sum, sol; int viz[DIM], niv[DIM], t[DIM]; vector<int> v[DIM]; void dfs(int nod){ viz[nod] = 1; sum += niv[nod]; for(int i = 0; i < v[nod].size(); i++){ int vecin = v[nod][i]; if(viz[vecin] == 0){ viz[vecin] = 1; niv[vecin] = 1 + niv[nod]; t[vecin] = nod; } } for(int i = 0; i < v[nod].size(); i++){ int vecin = v[nod][i]; if(t[vecin] == nod){ dfs(vecin); } } } int main(){ cin>> n; for(i = 1; i <= n; i++){ cin>> m; for(j = 1; j <= m; j++){ cin>> x; v[x].push_back(i); } } sol = 1000000000; for(i = 1; i <= n; i++){ memset(viz, 0, sizeof(viz) ); memset(t, 0, sizeof(t) ); niv[i] = 1; t[i] = 0; sum = 0; dfs(i); sol = min(sol, sum); } cout<< sol; }

Compilation message (stderr)

bosses.cpp: In function 'void dfs(int)':
bosses.cpp:12:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < v[nod].size(); i++){
                    ~~^~~~~~~~~~~~~~~
bosses.cpp:20:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     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...