Submission #88873

#TimeUsernameProblemLanguageResultExecution timeMemory
88873sailormoonTriumphal arch (POI13_luk)C++14
Compilation error
0 ms0 KiB
#include <string> #include <algorithm> #include <iostream> #include <vector> #include <unordered_set> using namespace std; int canHandle(int v, int crs); vector<vector<int>> graph (300000001); // size bool visited[300000001]; int main() { int n, a, b, start = 0, midpoint, end; // n -> towns, a -> from, b -> to scanf("%d", &n); end = n; // last point n--; while (n--) { 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) { midpoint = (start + end) / 2; visited = { false }; if (canHandle(1, midpoint) == 0) end = midpoint; else start = ++midpoint; } printf("%d\n", start); return 0; } int canHandle(int v, int crs) { int num_children = 0, need_crews = 0; visited[v] = true; for (int i = 0; i < graph[v].size(); i++) { if (!visited[graph[v][i]]) { num_children++; need_crews += canHandle(graph[v][i], crs); } } return max(0, num_children + need_crews - crs); }

Compilation message (stderr)

luk.cpp: In function 'int main()':
luk.cpp:28:27: error: assigning to an array from an initializer list
         visited = { false }; 
                           ^
luk.cpp: In function 'int canHandle(int, int)':
luk.cpp:44:23: 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:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
luk.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &a, &b);
         ~~~~~^~~~~~~~~~~~~~~~~