Submission #73998

#TimeUsernameProblemLanguageResultExecution timeMemory
73998claudyBosses (BOI16_bosses)C++14
0 / 100
7 ms4032 KiB
# pragma GCC optimize("O3") # include <bits/stdc++.h> std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}}; # define ll long long # define clock (clock() * 1000.0 / CLOCKS_PER_SEC) # define rc(s) return cout << s,0 # define rcg(s) cout << s;exit(0) # define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0); # define db(x) cerr << #x << " = " << x << '\n' # define pb push_back # define mp make_pair # define all(s) s.begin(),s.end() # define sz(x) (int)((x).size()) //# define int ll using namespace std; int n,k,x; vector<int>vec[1 << 17]; int viz[1 << 17]; int f(int nod) { queue<pair<int,int>>q; memset(viz,0,sizeof(viz)); q.push(mp(nod,1)); int cnt = 1; int x = 0; while(!q.empty()) { int v = q.front().first; int cst = q.front().second; q.pop(); viz[v] = 1; x += cst; for(auto it : vec[v]) { if(!viz[it]){ cnt++; q.push(mp(it,cst + 1)); } } } return x; } int32_t main(){_ //freopen("input","r",stdin); cin >> n; for(int i = 1;i <= n;i++) { cin >> k; while(k--) { cin >> x; vec[x].pb(i); } } int ans = 1e9; for(int i = 1;i <= n;i++) { ans = min(ans,f(i)); } rc(ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...