제출 #509282

#제출 시각아이디문제언어결과실행 시간메모리
509282sumit_kk10Bosses (BOI16_bosses)C++17
0 / 100
20 ms27628 KiB
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define pb push_back
#define F first 
#define S second
using namespace std;
const int N = 1e6 + 5, MOD = 1e9 + 7;
int n, sum = 0;
vector<int> g[N], vis(N);

int dfs(int node, int par){
	if(vis[node])
		return 0;
	vis[node] = 1;
	int cur = 1;
	// cout << node << ' ';
	for(auto k : g[node])
		cur += dfs(k, node);
	sum += cur;
	return cur;
}

void solve(){
	cin >> n;
	for(int i = 1; i <= n; ++i){
		int x;
		cin >> x;
		for(int j = 0; j < x; ++j){
			int k;
			cin >> k;
			g[k].pb(i);
		}
	}
	int ans = INT_MAX;
	for(int root = 1; root <= n; ++root){
		for(int j = 1; j <= n; ++j) vis[j] = 0;
		sum = 0;
		dfs(root, 0);
		bool ok = 1;
		for(int j = 1; j <= n; ++j)
			if(!vis[j])
				ok = 0;
		// cout << sum << endl;
		if(ok) ans = min(ans, sum);
	}
	cout << ans << '\n';
}

int main() {
    fast;
    int t = 1;
    // cin >> t;
    while(t--)
    	solve();
	return 0;
}

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

bosses.cpp: In function 'int main()':
bosses.cpp:54:5: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   54 |     while(t--)
      |     ^~~~~
bosses.cpp:56:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   56 |  return 0;
      |  ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...