제출 #52403

#제출 시각아이디문제언어결과실행 시간메모리
52403TadijaSebezBosses (BOI16_bosses)C++11
100 / 100
811 ms1408 KiB
#include <stdio.h> #include <vector> #include <queue> using namespace std; const int N=5050; const int inf=1e9+7; vector<int> E[N]; int dep[N],ans=inf; int min(int a, int b){ return a>b?b:a;} queue<int> q; void BFS(int u, int n) { int i; for(i=1;i<=n;i++) dep[i]=inf; q.push(u); dep[u]=1; int sol=0; while(q.size()) { int x=q.front(); q.pop(); sol+=dep[x]; for(i=0;i<E[x].size();i++) { int y=E[x][i]; if(dep[y]>dep[x]+1) { dep[y]=dep[x]+1; q.push(y); } } } for(i=1;i<=n;i++) if(dep[i]==inf) return; ans=min(ans,sol); } int main() { int n,i,sz,x; scanf("%i",&n); for(i=1;i<=n;i++) { scanf("%i",&sz); while(sz--) scanf("%i",&x),E[x].push_back(i); } for(i=1;i<=n;i++) BFS(i,n); printf("%i\n",ans); return 0; }

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

bosses.cpp: In function 'void BFS(int, int)':
bosses.cpp:23:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(i=0;i<E[x].size();i++)
           ~^~~~~~~~~~~~
bosses.cpp: In function 'int main()':
bosses.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i",&n);
  ~~~~~^~~~~~~~~
bosses.cpp:42:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%i",&sz);
   ~~~~~^~~~~~~~~~
bosses.cpp:43:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   while(sz--) scanf("%i",&x),E[x].push_back(i);
               ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...