# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
77034 | farukkastamonuda | Bosses (BOI16_bosses) | C++14 | 739 ms | 1556 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define li 10005
#define lo long long
#define inf 1000000000000000000
using namespace std ;
lo int n,x,y,mark[li],cnt,ans=inf,val;
vector<lo int> v[li];
int main(){
scanf("%lld",&n);
for(int i=1;i<=n;i++){
scanf("%lld",&x);
for(int j=1;j<=x;j++){
scanf("%lld",&y);
v[y].push_back(i);
}
}
lo int cev=0;
for(int i=1;i<=n;i++){
cev=0;
val=0;
memset(mark,0,sizeof(mark));
queue<int> q;
q.push(i);
cnt=0;
mark[i]=1;
while(!q.empty()){
int vv=q.front();
q.pop();
cnt++;
val+=mark[vv];
if(val>=ans) break;
for(int j=0;j<(int)v[vv].size();j++){
int go=v[vv][j];
if(mark[go]) continue;
mark[go]=mark[vv]+1;
q.push(go);
}
}
if(cnt==n) ans=min(ans,val);
}
printf("%lld\n",ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |