Submission #146071

#TimeUsernameProblemLanguageResultExecution timeMemory
146071mat_vBosses (BOI16_bosses)C++14
67 / 100
1552 ms1016 KiB
#include <bits/stdc++.h> #define mod 1000000007 #define pb push_back #define mid(l, r) ((l)+(r))/2 #define len(a) (a).length() #define sz(a) (a).size() #define xx first #define yy second #define inf int(2e9) #define ff(i, a, b) for(int (i) = (a); (i) <= (b); ++(i)) #define fb(i, a, b) for(int (i) = (a); (i) >= (b); --(i)) #define maxn 5005 using namespace std; typedef long long ll; typedef pair<int,int> pii; template<class T> void print(const T niz[], const int siz) { for(int i=0;i<siz;i++) cout << niz[i] << " "; cout << endl; } int n; int cnt; vector<int>ngraf[maxn]; vector<int>graf[maxn]; bool bio[maxn]; ll resela = 1e9; ll res; ll dfs(int x){ ll sta = 1; for(auto c:ngraf[x])sta += dfs(c); res += sta; return sta; } void bfs(int src){ cnt = 0; res = 0; ff(i,1,n){ ngraf[i].clear(); bio[i] = 0; } queue<int>q; q.push(src); while(!q.empty()){ ++cnt; int tren = q.front(); bio[tren] = 1; q.pop(); for(auto c:graf[tren]){ if(!bio[c]){ bio[c] = 1; q.push(c); ngraf[tren].pb(c); } } } ll pom = 0;; if(cnt != n)return; pom = dfs(src); resela = min(resela, res); //resela = min(resela,pom); //cout << src << " " << pom << endl; } int main() { ios_base::sync_with_stdio(false); cin >> n; ff(i,1,n){ int k; cin >> k; ff(j,1,k){ int a; cin >> a; graf[a].pb(i); } } ff(i,1,n){ bfs(i); } cout << resela; return 0; }

Compilation message (stderr)

bosses.cpp: In function 'void bfs(int)':
bosses.cpp:62:8: warning: variable 'pom' set but not used [-Wunused-but-set-variable]
     ll pom = 0;;
        ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...