제출 #985362

#제출 시각아이디문제언어결과실행 시간메모리
985362Octa_pe_infoBosses (BOI16_bosses)C++14
0 / 100
0 ms348 KiB
#include <iostream> #include <vector> #include <queue> using namespace std; vector<vector<int>>tabel; vector<bool>viz; vector<int>pasi; int cnt=0,stot=0; void bfs(int nod){ queue<int>q; viz[nod]=1; q.push(nod); pasi[nod]=0; while(!q.empty()){ int curent=q.front(); q.pop(); for(auto i : tabel[curent]) if(!viz[i]){ viz[i]=1; pasi[i]=pasi[curent]+1; q.push(i); cnt++; } } } int dfs(int nod){ int sal=1; for(auto i : tabel[nod]) if(pasi[i]-1==pasi[nod]) sal+=dfs(i); stot+=sal; return sal; } int main() { int n; cin>>n; tabel.resize(n+1); for(int i=1;i<=n;i++){ int k; cin>>k; for(int j=1;j<=k;j++){ int x; cin>>x; tabel[x].push_back(i); } } int salmin=1e9; for(int i=1;i<=n;i++){ viz.resize(n+1,0); pasi.resize(n+1,0); cnt=0; bfs(i); if(cnt==n-1){ stot=0; int aux=dfs(i); salmin=min(salmin,stot); } } cout<<salmin; return 0; }

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

bosses.cpp: In function 'int main()':
bosses.cpp:74:17: warning: unused variable 'aux' [-Wunused-variable]
   74 |             int aux=dfs(i);
      |                 ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...