이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |