제출 #886760

#제출 시각아이디문제언어결과실행 시간메모리
886760BBart888Bosses (BOI16_bosses)C++14
0 / 100
1 ms604 KiB
#include <cstdio> #include <iostream> #include <vector> #include <list> #include <string> #include <set> #include <map> #include <algorithm> #include <fstream> #include <cmath> #include <queue> #include <stack> #include <cassert> #include <cstring> #include <climits> #include <functional> #include<cstdlib> //#include "arc.h" using namespace std; typedef pair<int, int> PII; typedef vector<int> VI; typedef long long LL; const int MAXN = 5e3 + 11; using ll = long long; typedef vector<int> lnum; const int base = 1e9; const ll mod1 = 1e9 + 7; const ll mod2 = 1000000021; const ll P = 31; /* void setIO(string name = "") { cin.tie(0)->sync_with_stdio(0); // see /general/fast-io if ((name.size())) { freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output freopen((name + ".out").c_str(), "w", stdout); } } */ int n; vector<int> adj[MAXN]; vector<int> lst[MAXN]; bool used[MAXN]; int sz = 0; ll num[MAXN]; ll ans = 1e18; void calc(int v, int p) { sz++; ll sum = 0; for (auto u : adj[v]) { if (u == p) continue; calc(u, v); sum += num[u]; } num[v] = sum + 1; } void build(int v, int p) { used[v] = true; for (auto u : lst[v]) { if (u == p || used[u]) continue; adj[v].push_back(u); adj[u].push_back(v); build(u, v); } } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); //setIO("time"); cin >> n; for (int i = 1; i <= n; i++) { int k; cin >> k; for (int j = 0; j < k; j++) { int v; cin >> v; lst[v].push_back(i); } } for (int root = 1; root <= n; root++) { for (int i = 1; i <= n; i++) { adj[i].clear(); used[i] = num[i] = 0; sz = 0; } build(root, root); calc(root, root); ll curr = 0; for (int i = 1; i <= n; i++) curr += num[i]; if (sz == n) ans = min(ans, curr); } cout << ans << '\n'; return 0; }

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

bosses.cpp: In function 'int main()':
bosses.cpp:113:21: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  113 |    used[i] = num[i] = 0;
      |              ~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...