# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
197532 | dndhk | Bosses (BOI16_bosses) | C++14 | 982 ms | 796 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAX_N = 5000;
const int INF = 100000;
int N;
vector<int> gp[MAX_N+1];
int dist[MAX_N+1];
deque<int> dq;
int ans;
int main(){
scanf("%d", &N);
for(int i=1; i<=N; i++){
int x, y;
scanf("%d", &x);
while(x--){
scanf("%d", &y);
gp[y].pb(i);
}
}
for(int i=1; i<=N; i++){
for(int j=1; j<=N; j++){
dist[j] = INF;
}
dist[i] = 1;
dq.pb(i);
while(!dq.empty()){
int now = dq.front(); dq.pop_front();
for(int i : gp[now]){
if(dist[i]>dist[now]+1){
dist[i] = dist[now]+1;
dq.pb(i);
}
}
}
int sum = 0;
for(int j=1; j<=N; j++){
sum+=dist[j];
}
if(i==1) ans = sum;
else ans = min(sum, ans);
}
cout<<ans;
}
컴파일 시 표준 에러 (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... |