Submission #81540

#TimeUsernameProblemLanguageResultExecution timeMemory
81540arman_ferdousBosses (BOI16_bosses)C++17
0 / 100
2 ms632 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = 5010;
int n;
vector<int> g[N];

int val[N];
int dfs(int u) {
	val[u] = 1;
	for(int v : g[u]) if(val[v] == -1) 
		val[u] += dfs(v);
	return val[u];
}

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		int sz, j; scanf("%d", &sz);
		while(sz--) {
			scanf("%d", &j);
			g[j].push_back(i);
		}
	}
	int ans = (int)2e9;
	for(int i = 1; i <= n; i++) {
		memset(val,-1,sizeof val);
		dfs(i); int here = 0;
		for(int j = 1; j <= n; j++)
			here += val[j];
		ans = min(ans, here);
	} printf("%d\n", ans);
	return 0;
}

Compilation message (stderr)

bosses.cpp: In function 'int main()':
bosses.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
bosses.cpp:19:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int sz, j; scanf("%d", &sz);
              ~~~~~^~~~~~~~~~~
bosses.cpp:21:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &j);
    ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...