제출 #705342

#제출 시각아이디문제언어결과실행 시간메모리
705342ToroTNBosses (BOI16_bosses)C++14
0 / 100
1 ms340 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define ll long long ll n,m,sub,d[5005],u,type,sum,ans=1e9; vector<ll> v[5005]; queue<ll> q; int main() { scanf("%lld",&n); for(int i=1;i<=n;i++) { scanf("%lld",&m); for(int j=1;j<=m;j++) { scanf("%lld",&sub); v[sub].pb(i); } } for(int i=1;i<=n;i++) { memset(d,-1,sizeof d); d[i]=1; q.push(i); while(!q.empty()) { u=q.front(); q.pop(); for(auto node:v[u]) { if(d[node]==-1) { d[node]=d[u]+1; q.push(node); } } } sum=0; type=0; for(int j=1;j<=n;j++) { if(d[j]==-1)type=-1; sum+=d[j]; } if(type==0) { ans=min(ans,sum); } } printf("%lld\n",sum); }

컴파일 시 표준 에러 (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]
   10 |     scanf("%lld",&n);
      |     ~~~~~^~~~~~~~~~~
bosses.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%lld",&m);
      |         ~~~~~^~~~~~~~~~~
bosses.cpp:16:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |             scanf("%lld",&sub);
      |             ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...