# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
880759 |
2023-11-30T03:00:26 Z |
irmuun |
Bosses (BOI16_bosses) |
C++17 |
|
0 ms |
348 KB |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n;
cin>>n;
vector<int>adj[n+1];
for(int i=1;i<=n;i++){
int k;
cin>>k;
for(int j=1;j<=k;j++){
int x;
cin>>x;
adj[x].pb(i);
}
}
ll ans=1e9;
vector<bool>used(n+1,0);
int tot[n+1];
vector<int>g[n+1];
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
g[j].clear();
}
fill(all(used),0);
queue<int>q;
q.push(i);
used[i]=true;
while(!q.empty()){
int x=q.front();
q.pop();
for(auto y:adj[x]){
if(!used[y]){
used[y]=true;
g[x].pb(y);
q.push(y);
}
}
}
function <void(int,int)> dfs=[&](int x,int p){
tot[x]=1;
for(auto y:g[x]){
if(y!=p){
dfs(y,x);
tot[x]+=tot[y];
}
}
};
dfs(i,0);
ll cur=0;
for(int i=1;i<=n;i++){
cur+=tot[i];
}
ans=min(ans,cur);
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |