제출 #134576

#제출 시각아이디문제언어결과실행 시간메모리
134576junodeveloperBosses (BOI16_bosses)C++14
100 / 100
989 ms760 KiB
#include <bits/stdc++.h> #define sz(x) ((int)x.size()) #define all(x) (x).begin(), (x).end() using namespace std; typedef long long ll; typedef long double ld; int n, D[5010], C[5010]; vector<int> adj[5010]; int main() { int i,j; scanf("%d",&n); for(i=1;i<=n;i++) { int k; scanf("%d",&k); for(j=1;j<=k;j++) { int x; scanf("%d",&x); adj[x].push_back(i); } } queue<int> q; int u,mx,tot,res=2e9; for(i=1;i<=n;i++) { fill(D+1,D+n+1,-1); fill(C,C+n+1,0); mx=D[i]=0; q.push(i); tot=0; while(!q.empty()) { u=q.front();q.pop(); C[D[u]]++; mx=max(mx,D[u]); tot++; for(auto& it:adj[u]){ if(D[it]==-1) { D[it]=D[u]+1; q.push(it); } } } if(tot<n) continue; int v=0; for(j=mx;j>=0;j--) { C[j]+=C[j+1]; v+=C[j]; } res=min(res,v); } printf("%d",res); return 0; }

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

bosses.cpp: In function 'int main()':
bosses.cpp:11:7: 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",&x);
    ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...