# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
303787 | Hemimor | Bosses (BOI16_bosses) | C++14 | 737 ms | 716 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 <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int n;
vvi g;
int main(){
cin>>n;
g=vvi(n);
for(int i=0;i<n;i++){
int m;
scanf("%d",&m);
for(int j=0;j<m;j++){
int x;
scanf("%d",&x);
x--;
g[x].push_back(i);
}
}
int res=inf;
for(int i=0;i<n;i++){
vi d(n,inf);
d[i]=0;
queue<int> q;
q.push(i);
while(!q.empty()){
int v=q.front();
q.pop();
for(auto u:g[v]) if(d[u]==inf){
d[u]=d[v]+1;
q.push(u);
}
}
int tmp=0;
for(auto j:d){
tmp+=j+1;
if(tmp>inf) break;
}
res=min(res,tmp);
}
printf("%d\n",res);
}
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... |