제출 #91783

#제출 시각아이디문제언어결과실행 시간메모리
91783TieuphongBosses (BOI16_bosses)C++11
22 / 100
25 ms632 KiB
/***************************************************************************/ /********************** LANG TU HAO HOA **********************************/ /***************************************************************************/ #include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define FORD(i, a, b) for (int i = (a); i >= (b); --i) #define pii pair<int, int> #define sz(x) ((int) x.size()) #define PB push_back #define PF push_front #define MP make_pair #define ll long long #define F first #define S second #define maxc 1000000007 #define MOD 1000000007 #define base 107 #define eps 1e-6 #define pi acos(-1) #define N 5003 #define K 10004 #define task "" #define remain(x) ((x > MOD) ? (x - MOD) : x) using namespace std; int n, f[N], cnt = 0, in[N]; pii canh[K]; vector <int> ke[N]; void DFS(int u) { f[u] = 1; for (auto v : ke[u]) { DFS(v); f[u] += f[v]; } } void Sub1() { int res = maxc; FOR(i, 1, n) { int k; cin >> k; FOR(j, 1, k) { int x; cin >> x; canh[++cnt] = MP(x, i); } } int Last = (1 << cnt) - 1; FOR(x, 0, Last) { if (__builtin_popcount(x) != n-1) continue; FOR(i, 1, n) ke[i].clear(), in[i] = 0, f[i] = 0; FOR(i, 1, cnt) { if ((x >> (i-1)) & 1) { ke[canh[i].F].PB(canh[i].S); in[canh[i].S]++; } } int root, sl = 0; FOR(i, 1, n) { if (!in[i]) { root = i; sl++; } } if (sl > 1) continue; DFS(root); if (*min_element(f+1, f+n+1) == 0) continue; res = min(res, accumulate(f+1, f+n+1, 0)); } cout << res; exit(0); } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); //freopen(task".inp", "r", stdin); //freopen(task".out", "w", stdout); cin >> n; Sub1(); return 0; }

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

bosses.cpp: In function 'void Sub1()':
bosses.cpp:78:12: warning: 'root' may be used uninitialized in this function [-Wmaybe-uninitialized]
         DFS(root);
         ~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...