제출 #218609

#제출 시각아이디문제언어결과실행 시간메모리
218609Ruxandra985Bosses (BOI16_bosses)C++14
0 / 100
5 ms512 KiB
#include <bits/stdc++.h> #define DIMN 5010 using namespace std; priority_queue <pair <int,int> > h; vector <int> v[DIMN]; int d[DIMN] , tt[DIMN] , lvl[DIMN] , under[DIMN]; int dfs (int nod){ int i , vecin , sol = 0; d[nod] = 1; for (i = 0 ; i < v[nod].size() ; i++){ vecin = v[nod][i]; if (tt[vecin] == nod){ sol += dfs(vecin); d[nod] += d[vecin]; } } return sol + d[nod]; } int main() { FILE *fin = stdin; FILE *fout = stdout; int n , i , k , x , sol , root , nod , vecin , niv , j; fscanf (fin,"%d",&n); for (i = 1 ; i <= n ; i++){ fscanf (fin,"%d",&k); for (j = 1 ; j <= k ; j++){ fscanf (fin,"%d",&x); v[x].push_back(i); /// x poate fi seful lui i } } sol = 2000000000; for (root = 1 ; root <= n ; root++){ h.push(make_pair(-1 , root)); memset (lvl , 0 , sizeof(lvl)); memset (under , 0 , sizeof(under)); lvl[root] = 1; tt[root] = 0; while (!h.empty()){ nod = h.top().second; niv = -h.top().first; h.pop(); if (lvl[nod] != niv) continue; for (i = 0 ; i < v[nod].size() ; i++){ vecin = v[nod][i]; if (lvl[vecin] == 0 || lvl[vecin] > lvl[nod] + 1){ lvl[vecin] = lvl[nod] + 1; under[tt[vecin]]--; under[nod]++; tt[vecin] = nod; h.push(make_pair(-lvl[vecin] , vecin)); } else if (lvl[vecin] == lvl[nod] + 1 && under[nod] < under[tt[vecin]]){ lvl[vecin] = lvl[nod] + 1; under[tt[vecin]]--; under[nod]++; tt[vecin] = nod; h.push(make_pair(-lvl[vecin] , vecin)); } } } sol = min(sol , dfs(root)); } fprintf (fout,"%d",sol); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

bosses.cpp: In function 'int dfs(int)':
bosses.cpp:11:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i = 0 ; i < v[nod].size() ; i++){
                  ~~^~~~~~~~~~~~~~~
bosses.cpp: In function 'int main()':
bosses.cpp:50:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (i = 0 ; i < v[nod].size() ; i++){
                          ~~^~~~~~~~~~~~~~~
bosses.cpp:27:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%d",&n);
     ~~~~~~~^~~~~~~~~~~~~
bosses.cpp:29:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         fscanf (fin,"%d",&k);
         ~~~~~~~^~~~~~~~~~~~~
bosses.cpp:31:20: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             fscanf (fin,"%d",&x);
             ~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...