# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
967894 |
2024-04-23T04:47:13 Z |
PM1 |
Bosses (BOI16_bosses) |
C++17 |
|
1 ms |
348 KB |
#include <bits/stdc++.h>
using namespace std;
const int mxn=5e3+5;
int n,ans=1e9,mark[mxn];
vector<int>v[mxn];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
int k;
cin>>k;
while(k--){
int x;
cin>>x;
v[x].push_back(i);
}
}
for(int i=1;i<=n;i++){
memset(mark,0,sizeof mark);
int res=0;
queue<int>q;
mark[i]=1;
q.push(i);
while(!q.empty()){
int x=q.front();
q.pop();
res+=mark[x];
for(auto j:v[x]){
if(!mark[j]){
mark[j]=mark[x]+1;
q.push(j);
}
}
}
ans=min(res,ans);
}
cout<<ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |