Submission #330269

#TimeUsernameProblemLanguageResultExecution timeMemory
330269Ruba_KBosses (BOI16_bosses)C++14
0 / 100
1 ms492 KiB
#include<bits/stdc++.h> using namespace std; #define debug(x) cout << '[' << #x << " is: " << x << "] " << endl; #define imod(a , n) (a % n + n ) % n #define fastio ios_base::sync_with_stdio(false);cin.tie(0); #define inF freopen("file.txt","r",stdin ); #define outF freopen("perimeter.out" , "w" , stdout ) ; #define sor(v) sort(v.begin() , v.end()); #define print(v) for(auto f : v ) cout << f << " " ; #define rsor(v) sort(v.rbegin() , v.rend()); #define rev(v) reverse(v.begin() , v.end()); #define ll long long //#define int ll #define pii pair<int , int > const int N = 5e3 + 5 , M = N * 4 ; const ll MOD = 1e9 + 7 , oo = 1e9 , OO = 1e18 ; //37 int di[] = {1 , -1 , 0 , 0}; int dj[] = {0 , 0 , 1 , -1}; int n ; vector<int> adj[N]; int vis[N] , vid ; int sum = 0 ; int dfs(int i){//debug(i); vis[i] = vid ; int ret = 0 ; for(auto f : adj[i]){ if(vis[f] == vid)continue ; ret += dfs(f); } sum += ret + 1 ; return ret + 1 ; } int32_t main() { // inF; // inF;outF; fastio; // Dont Forget memset cin >> n ; int mn = oo ; for(int i = 1 ; i <= n ; i ++){ int k ; cin >> k ; while(k--){ int a ; cin >> a ; adj[a].push_back(i); } } vid ++ ; dfs(3); for(int i = 1 ; i <= n ; i ++){ vid ++ ; dfs(i); mn = min(mn , sum); sum = 0 ; } cout << mn ; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...