제출 #88917

#제출 시각아이디문제언어결과실행 시간메모리
88917zviki새로운 문제 (POI13_luk)C++14
100 / 100
1202 ms24436 KiB
#include <iostream> #include <algorithm> #include <vector> #include <unordered_set> #define avg(a ,b) ((a + b) / 2) #define ARR_SIZE 300050 using namespace std; int num_not_satisfy(char visited_set[], int num_workers, int city, vector<vector<int>> & map_of_cities) { int i, child_city, children, rec_res, num_children; i = 0, rec_res = 0, visited_set[city] = 1, children = map_of_cities[city].size(), num_children = 0; while (i < children){ child_city = map_of_cities[city][i]; if (visited_set[child_city] != 0) { goto nextiteration; } num_children++; rec_res += num_not_satisfy(visited_set, num_workers, child_city, map_of_cities); nextiteration: ; i++; } return ((num_children + rec_res - num_workers <= 0) ? 0 : (num_children + rec_res - num_workers)); } int main(int argc, char * argv[]) { int n, i = 0, res, bsearch_start, bsearch_end, bsearch_mid, road_from, road_to; cin >> n; vector<vector<int>> map_of_cities; while(i++ < n){ vector<int> temp; map_of_cities.push_back(temp); } i = 1; while (i++ < n) { cin >> road_from >> road_to; map_of_cities[road_from - 1].push_back(road_to - 1); map_of_cities[road_to - 1].push_back(road_from - 1); } bsearch_start = 0, bsearch_end = n; while (bsearch_start < bsearch_end) { bsearch_mid = avg(bsearch_start, bsearch_end); char visited_set[n + 5] = { 0 }; res = num_not_satisfy(visited_set, bsearch_mid, 0, map_of_cities); ((res != 0) ? (bsearch_start = bsearch_mid + 1) : (bsearch_end = bsearch_mid)); } res = bsearch_start; cout << res << endl; return 0; }
#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...