이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/// Be Kind :)
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Os")
/* Bitch, where you when I was walkin'?
Now I run the game, got the whole world talkin' */
/* You never likes us anyway, fuck your friendship, I meant it */
/* The Chanel or Balenciaga, Louis and Vuitton
She know I got Fendi, Prada when I hit Milan */
/* Niggas been counting me out
I'm counting my bullets, I'm loading my clips
I'm writing down names, I'm making a list */
/* I ran away, I don't think I'm coming back home */
#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
typedef int ll;
typedef pair<ll,ll> pll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll maxn=5e3+10, maxm=1e5+10, lg=23, mod=1e9+7, inf=1e18;
ll n;
vector<ll> g[maxn];
ll dis[maxn];
deque<ll> q;
int main(){
ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
ll k; cin>>k;
while(k--){
ll x; cin>>x;
g[x].pb(i);
}
}
ll ans=mod;
for(int sr=1;sr<=n;sr++){
memset(dis,69,sizeof(dis));
q.pb(sr), dis[sr]=0;
while(!q.empty()){
ll v=q.front(); q.pop_front();
for(auto u:g[v])if(dis[u]>dis[v]+1) dis[u]=dis[v]+1, q.pb(u);
}
ll nans=0;
for(int i=1;i<=n;i++){
if(dis[i]>=mod){ nans=mod; break; }
nans+=dis[i];
}
ans=min(ans,nans);
}
cout<<ans+n;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
bosses.cpp:34:58: warning: overflow in implicit constant conversion [-Woverflow]
const ll maxn=5e3+10, maxm=1e5+10, lg=23, mod=1e9+7, inf=1e18;
^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |