제출 #951524

#제출 시각아이디문제언어결과실행 시간메모리
951524Faisal_SaqibBosses (BOI16_bosses)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N=5e3+10; set<int> tp[N]; vector<int> ma[N]; int h[N],val[N]; void compute_answer(int v) { val[v]=0; for(auto ap:ma[v]) { compute_answer(ap); val[v]+=val[ap]; } val[v]++; } int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); int n; cin>>n; for(int i=1;i<=n;i++) { int k; cin>>k; for(int j=1;j<=k;j++) { int p; cin>>p; tp[p].insert(i); } } int ans=1e9; int deg= for(int i=1;i<=n;i++) { for(int ap=1;ap<=n;ap++) { ma[ap].clear(); h[ap]=1e9; } { //Time = O() queue<int> q; q.push(i); h[i]=0; while(q.size()) { int f=q.front(); q.pop(); for(auto ap:tp[f]) { if((h[ap]>(h[f]+1))) { h[ap]=h[f]+1; ma[f].push_back(ap); q.push(ap); } } } } compute_answer(i); int sum=0; for(int i=1;i<=n;i++) { if(h[i]==1e9) { sum=1e9; break; } sum+=val[i]; } ans=min(ans,sum); } cout<<ans<<'\n'; return 0; }

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

bosses.cpp: In function 'int main()':
bosses.cpp:37:5: error: expected primary-expression before 'for'
   37 |     for(int i=1;i<=n;i++)
      |     ^~~
bosses.cpp:37:17: error: 'i' was not declared in this scope
   37 |     for(int i=1;i<=n;i++)
      |                 ^
bosses.cpp:36:9: warning: unused variable 'deg' [-Wunused-variable]
   36 |     int deg=
      |         ^~~