| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 349313 | S2speed | Bosses (BOI16_bosses) | C++17 | 710 ms | 768 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#pragma GCC optimize ("Ofast")
#define all(x) x.begin() , x.end()
#define gcd __gcd
typedef long long int ll;
typedef pair<ll , ll> pll;
typedef pair<int , int> pii;
typedef long double db;
typedef pair<ll , pll> plll;
typedef pair<int , pii> piii;
const ll MAXN = 5e3 + 20 , md = 1e9 + 7;
// check problem statement
vector<int> adj[MAXN] , bfs;
int dis[MAXN];
int main(){ // check MAXN
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n , ans = 1e8;
cin>>n;
for(int i = 0 ; i < n ; i++){
ll k;
cin>>k;
for(int j = 0 ; j < k ; j++){
ll v;
cin>>v; v--;
adj[v].push_back(i);
}
}
for(int i = 0 ; i < n ; i++){
memset(dis , 63 , sizeof(dis));
dis[i] = 1;
int x = 0 , h = 0;
bfs.push_back(i);
while(x < bfs.size()){
int v = bfs[x];
for(auto u : adj[v]){
if(dis[u] > dis[v] + 1){
dis[u] = dis[v] + 1;
bfs.push_back(u);
}
}
x++;
}
bfs.clear();
for(int j = 0 ; j < n ; j++){
if(dis[j] > n){
h = 1e8;
break;
}
h += dis[j];
}
ans = min(ans , h);
}
cout<<ans<<'\n';
return 0;
}
/*
*/컴파일 시 표준 에러 (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... | ||||
