# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
88886 | zviki | 새로운 문제 (POI13_luk) | C++14 | 287 ms | 18768 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#define avg(a, b) ((a + b) / 2)
#define ARR_SIZE 300050
using namespace std;
vector<vector<int>> map_of_cities(ARR_SIZE);
int visited_set[ARR_SIZE];
int
num_not_satisfy(int num_workers, int city)
{
int i, child_city, children = map_of_cities[city].size(), rec_res, num_children = 0;
visited_set[city] = true;
for (i = 0, rec_res = 0; i < children; i++) {
child_city = map_of_cities[city][i];
if (visited_set[child_city] == false) {
num_children++;
rec_res += num_not_satisfy(num_workers, child_city);
}
}
if ((num_children + rec_res - num_workers) <= 0) {
return 0;
} else {
return children + rec_res - num_workers;
}
}
int
main()
{
int n, i, res, bsearch_start, bsearch_end, bsearch_mid, road_from, road_to;
scanf("%d", & n);
for (i = 1; i < n; i++) {
scanf("%d %d", &road_from, & road_to);
map_of_cities[road_from].push_back(road_to);
map_of_cities[road_to].push_back(road_from);
}
for (bsearch_start = 0, bsearch_end = n; bsearch_start < bsearch_end; ) {
bsearch_mid = avg(bsearch_start, bsearch_end);
memset(visited_set, false, ARR_SIZE * sizeof(bool));
res = num_not_satisfy(bsearch_mid, 1);
if (res != 0) {
bsearch_start = bsearch_mid + 1;
} else {
bsearch_end = bsearch_mid;
}
}
res = bsearch_start;
printf("%d\n", res);
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |