제출 #88908

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
889082018-12-09 18:56:42sailormoon새로운 문제 (POI13_luk)C++14
100 / 100
1417 ms59000 KiB
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int canHandle(int v, int crs, bool visited[]);
vector<vector<int>> graph (1000001); // size
int main() {
int n, a, b, start = 0, midpoint, end, cities; // n -> towns, a -> from, b -> to
scanf("%d", &n);
end = n; // last point
for (int i = 1; i < n; i++) {
scanf("%d %d", &a, &b);
graph[a].push_back(b);
graph[b].push_back(a);
}
// binary search for sufficient amount of crews
while (start < end) {
bool visited[1000001];
midpoint = (start + end) / 2;
for (int i = 1; i <= n; i++) visited[i] = false; // clear array
if (canHandle(1, midpoint, visited) == 0) end = midpoint;
else start = ++midpoint;
}
printf("%d\n", start);
return 0;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

컴파일 시 표준 에러 (stderr) 메시지

luk.cpp: In function 'int main()':
luk.cpp:11:46: warning: unused variable 'cities' [-Wunused-variable]
       int n, a, b, start = 0, midpoint, end, cities; // n -> towns, a -> from, b -> to
                                              ^~~~~~
luk.cpp: In function 'int canHandle(int, int, bool*)':
luk.cpp:36:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for (int i = 0; i < graph[v].size(); i++) {
                       ~~^~~~~~~~~~~~~~~~~
luk.cpp: In function 'int main()':
luk.cpp:12:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d", &n);
       ~~~~~^~~~~~~~~~
luk.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &a, &b);
         ~~~~~^~~~~~~~~~~~~~~~~
#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...