제출 #88886

#제출 시각아이디문제언어결과실행 시간메모리
88886zviki새로운 문제 (POI13_luk)C++14
0 / 100
287 ms18768 KiB
#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) 메시지

luk.cpp: In function 'int main()':
luk.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", & n);
  ~~~~~^~~~~~~~~~~
luk.cpp:40:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &road_from, & road_to);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...