제출 #676202

#제출 시각아이디문제언어결과실행 시간메모리
676202mseebacherBosses (BOI16_bosses)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;

int bfs(int x,int n){
	vector<bool> visi(n+1,0);
	q.push(x);
	ll cost = 1;
	dist[x] = 1;
	int cntr = 1;
	while(!q.empty()){
		int u = q.front(); q.pop();
		if(visi[u]) continue;
		visi[u] = true;
		for(auto s: ad[u]){
			if(!visi[s]){
				dist[s] = dist[u]+1;
				cost+=dist[s];
				q.push(s);
				cntr++;
			}
		}
	}
	return cntr == n ? cost: 1e9;
}

void solve(){
	
	int n; cin >> n;
	
	for(int i = 1;i<=n;i++){
		int x; cin >> x;
		for(int j = 0;j<x;j++){
			int g; cin >> g;
			ad[g].push_back(i);
		}
	}
	int mini = 1e9;
	for(int i = 1;i<=n;i++) {
		mini = min(mini,bfs(i,n));
	}
	cout << mini;
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout << fixed << setprecision(8);
 
   int t = 1;
  // cin >> t;
   while(t){
	solve();
	t--;  
	cout << "\n";
   }
   return 0;
}

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

bosses.cpp: In function 'int bfs(int, int)':
bosses.cpp:10:2: error: 'q' was not declared in this scope
   10 |  q.push(x);
      |  ^
bosses.cpp:12:2: error: 'dist' was not declared in this scope
   12 |  dist[x] = 1;
      |  ^~~~
bosses.cpp:18:15: error: 'ad' was not declared in this scope
   18 |   for(auto s: ad[u]){
      |               ^~
bosses.cpp: In function 'void solve()':
bosses.cpp:38:4: error: 'ad' was not declared in this scope
   38 |    ad[g].push_back(i);
      |    ^~