# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
213286 |
2020-03-25T12:09:51 Z |
Fasho |
Bosses (BOI16_bosses) |
C++14 |
|
941 ms |
896 KB |
#include <bits/stdc++.h>
#define N 10005
#define ll long long int
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
using namespace std;
ll n,m,ar[N],sum=INT_MAX,t,top,mark[N];
vector<int> v[N];
queue<lli> que;
void func(int ind)
{
memset(mark,0,sizeof(mark));
while(que.size())
que.pop();
que.push({ind,1});
while(que.size())
{
ll x=que.front().fi;
ll y=que.front().se;
que.pop();
if(mark[x])
continue;
mark[x]=y;
for(int i=0;i<v[x].size();i++)
{
ll z=v[x][i];
if(!mark[z])
que.push({z,y+1});
}
}
fo(i,1,n)
{
top+=mark[i];
if(mark[i]==0)
top+=1e10;
}
}
int main()
{
fast;
cin>>n;
fo(i,1,n)
{
int a;
cin>>a;
for(int j=1;j<=a;j++)
{
int b;
cin>>b;
v[b].pb(i);
}
}
fo(i,1,n)
{
top=0;
func(i);
sum=min(sum,top);
}
cout<<sum;
}
Compilation message
bosses.cpp: In function 'void func(int)':
bosses.cpp:42:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<v[x].size();i++)
~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
640 KB |
Output is correct |
2 |
Correct |
5 ms |
640 KB |
Output is correct |
3 |
Correct |
5 ms |
640 KB |
Output is correct |
4 |
Correct |
5 ms |
640 KB |
Output is correct |
5 |
Correct |
5 ms |
640 KB |
Output is correct |
6 |
Correct |
5 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
640 KB |
Output is correct |
2 |
Correct |
5 ms |
640 KB |
Output is correct |
3 |
Correct |
5 ms |
640 KB |
Output is correct |
4 |
Correct |
5 ms |
640 KB |
Output is correct |
5 |
Correct |
5 ms |
640 KB |
Output is correct |
6 |
Correct |
5 ms |
640 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
5 ms |
640 KB |
Output is correct |
9 |
Correct |
5 ms |
640 KB |
Output is correct |
10 |
Correct |
6 ms |
640 KB |
Output is correct |
11 |
Correct |
5 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
640 KB |
Output is correct |
2 |
Correct |
5 ms |
640 KB |
Output is correct |
3 |
Correct |
5 ms |
640 KB |
Output is correct |
4 |
Correct |
5 ms |
640 KB |
Output is correct |
5 |
Correct |
5 ms |
640 KB |
Output is correct |
6 |
Correct |
5 ms |
640 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
5 ms |
640 KB |
Output is correct |
9 |
Correct |
5 ms |
640 KB |
Output is correct |
10 |
Correct |
6 ms |
640 KB |
Output is correct |
11 |
Correct |
5 ms |
640 KB |
Output is correct |
12 |
Correct |
26 ms |
768 KB |
Output is correct |
13 |
Correct |
22 ms |
768 KB |
Output is correct |
14 |
Correct |
321 ms |
768 KB |
Output is correct |
15 |
Correct |
200 ms |
768 KB |
Output is correct |
16 |
Correct |
786 ms |
896 KB |
Output is correct |
17 |
Correct |
941 ms |
768 KB |
Output is correct |
18 |
Correct |
895 ms |
768 KB |
Output is correct |