제출 #91977

#제출 시각아이디문제언어결과실행 시간메모리
91977KamisamaBosses (BOI16_bosses)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <cstdio> #include <vector> #include <queue> using namespace std; const int maxn=5e3+7; int n,h[maxn],res; vector<int> adj[maxn]; inline void Bfs(const int &root){ queue<int> q; fill(h,h+n+1,0); h[root]=1; int sum=1,nEdges=0; q.push(root); while(q.size()){ int u=q.front(); q.pop(); for(int v: adj[u]){ if(h[v]) continue; nEdges++; h[v]=h[u]+1; sum+=h[v]; q.push(v); } } if(nEdges==n-1) res=min(res,sum); } inline void Read(int &x){ register char c; for(c=getchar();c>'9'||c<'0';c=getchar()); for(x=0;'0'<=c&&c<='9';c=getchar()) x=10*x+c-'0'; } inline void Write(const int &x){ if(x>9) Write(x/10); putchar(x%10+'0'); } int main(){ Read(n); for(int i=1,k=0;i<=n;i++){ Read(k); for(int j=1,x=0;j<=k;j++) Read(x), adj[x].push_back(i); } for(int i=1,res=(int)1e9+7;;i<=n;i++) Bfs(i); Write(res); return 0; }

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

bosses.cpp: In function 'int main()':
bosses.cpp:43:34: warning: for increment expression has no effect [-Wunused-value]
     for(int i=1,res=(int)1e9+7;;i<=n;i++) Bfs(i);
                                 ~^~~
bosses.cpp:43:37: error: expected ')' before ';' token
     for(int i=1,res=(int)1e9+7;;i<=n;i++) Bfs(i);
                                     ^
bosses.cpp:43:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(int i=1,res=(int)1e9+7;;i<=n;i++) Bfs(i);
     ^~~
bosses.cpp:43:38: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for(int i=1,res=(int)1e9+7;;i<=n;i++) Bfs(i);
                                      ^
bosses.cpp:43:17: warning: unused variable 'res' [-Wunused-variable]
     for(int i=1,res=(int)1e9+7;;i<=n;i++) Bfs(i);
                 ^~~
bosses.cpp:43:38: error: 'i' was not declared in this scope
     for(int i=1,res=(int)1e9+7;;i<=n;i++) Bfs(i);
                                      ^