제출 #68906

#제출 시각아이디문제언어결과실행 시간메모리
68906alenam0161Bosses (BOI16_bosses)C++17
100 / 100
782 ms952 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back const int N = 5007; vector<int> g[N],g1[N]; int dis[N]; int main() { int n; scanf("%d",&n); pair<int,int> mb={-1e9,-1e9}; for(int i=1;i<=n;++i){ int k; scanf("%d",&k); for(int j=0;j<k;++j){ int p; scanf("%d",&p); g[p].pb(i); mb=max(mb,{(int)g[p].size(),p}); } } int ans=1e9; for(int i=1;i<=n;++i){ if(g[i].size()==0)continue; queue<int> q; q.push(i); memset(dis,0,sizeof(dis)); dis[i]=1; int hw=1; int cur=1; while(!q.empty()){ int v=q.front();q.pop(); for(auto to:g[v]){ if(dis[to]>0)continue; q.push(to); dis[to]=dis[v]+1; hw++; cur+=dis[to]; } } if(hw==n){ // cur=0; // dfs(i); ans=min(ans,cur); } } cout<<ans<<endl; return 0; }

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

bosses.cpp: In function 'int main()':
bosses.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
bosses.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&k);
   ~~~~~^~~~~~~~~
bosses.cpp:17:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&p);
    ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...