제출 #438175

#제출 시각아이디문제언어결과실행 시간메모리
438175Urvuk3Bosses (BOI16_bosses)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const ll MAXN=1e6,INF=1e10 ; #define fi first #define se second #define pll pair<ll,ll> #define pii pair<int,int> #define mid (l+r)/2 #define sz(a) int((a).size()) #define all(a) a.begin(),a.end() #define mod 1000000007LL #define endl "\n" #define PRINT(x) cout<<#x<<'-'<<x<<endl ll n, m, k, q, l, r, x, y, z, res=INF, tmp=0; string s,t; vector<int> adj[MAXN]; ll dist[MAXN]; bool visited[MAXN]; void bfs(int x){ queue<int> q; dist[x]=1; visited[x]=true; q.push(x); while(!q.empty()){ int s=q.front(); q.pop(); for(v:adj[s]){ if(visited[v]) continue; visited[v]=true; dist[v]=dist[s]+1; q.push(v); } } } void solve(){ cin>>n; for(int i=1;i<=n;i++){ cin>>q; for(int j=0;j<q;j++){ cin>>x; adj[x].push_back(i); } } for(int i=1;i<=n;i++){ memset(visited,false,sizeof(visited)); memset(dist,0,sizeof(dist)); tmp=0; bfs(i); for(int i=1;i<=n;i++){ if(!visited[i]) continue; } for(int i=1;i<=n;i++){ tmp+=dist[i]; } res=min(res,tmp); } cout<<res<<endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); //freopen(".in","r",stdin); //freopen(".out","w",stdout); int t; //cin>>t; t=1; while(t--){ solve(); } return 0; }

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

bosses.cpp: In function 'void bfs(int)':
bosses.cpp:31:14: error: found ':' in nested-name-specifier, expected '::'
   31 |         for(v:adj[s]){
      |              ^
      |              ::
bosses.cpp:31:13: error: 'v' has not been declared
   31 |         for(v:adj[s]){
      |             ^
bosses.cpp:37:5: error: expected primary-expression before '}' token
   37 |     }
      |     ^
bosses.cpp:36:10: error: expected ';' before '}' token
   36 |         }
      |          ^
      |          ;
   37 |     }
      |     ~     
bosses.cpp:37:5: error: expected primary-expression before '}' token
   37 |     }
      |     ^
bosses.cpp:36:10: error: expected ')' before '}' token
   36 |         }
      |          ^
      |          )
   37 |     }
      |     ~     
bosses.cpp:31:12: note: to match this '('
   31 |         for(v:adj[s]){
      |            ^
bosses.cpp:37:5: error: expected primary-expression before '}' token
   37 |     }
      |     ^