# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
330269 |
2020-11-24T11:09:21 Z |
Ruba_K |
Bosses (BOI16_bosses) |
C++14 |
|
1 ms |
492 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Incorrect |
1 ms |
492 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |