#3797
Se dau un arbore cu N
noduri și rădăcina în nodul 1
al cărui muchii au lungimi exprimate prin numere naturale nenule și Q
query-uri de forma u v
. Pentru fiecare query să se afle suma lungimilor tuturor drumurilor distincte de la un nod aflat în subarborele cu rădăcina în nodul u
la un nod aflat în subarborele cu rădăcina în nodul v
modulo \( {10}^{9} + 7 \)(lungimea unui drum este egală cu suma lungimilor tuturor muchiilor ce îl alcătuiesc).
Problema | paths_sums | Operații I/O |
![]() |
---|---|---|---|
Limita timp | 0.6 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #56607099 | Utilizator | |
Fișier | paths_sums.cpp | Dimensiune | 1.74 KB |
Data încărcării | 27 Februarie 2025, 10:02 | Scor / rezultat | Eroare de compilare |
paths_sums.cpp:4:22: warning: missing terminating ' character [enabled by default] const int MAX_N = 200'000; ^ paths_sums.cpp:4:1: error: missing terminating ' character const int MAX_N = 200'000; ^ paths_sums.cpp:6:18: warning: multi-character character constant [-Wmultichar] const int MOD = 1'000'000'007; ^ paths_sums.cpp:6:26: warning: missing terminating ' character [enabled by default] const int MOD = 1'000'000'007; ^ paths_sums.cpp:6:1: error: missing terminating ' character const int MOD = 1'000'000'007; ^ paths_sums.cpp:5:1: error: expected ',' or ';' before 'const' const int MAX_LOG = 18; ^ paths_sums.cpp:6:18: error: expected ',' or ';' before '\x303030' const int MOD = 1'000'000'007; ^ paths_sums.cpp:12:8: error: 'MAX_LOG' was not declared in this scope int up[MAX_LOG][MAX_N]; ^ paths_sums.cpp:14:13: error: 'Edge' was not declared in this scope std::vector<Edge> adj[MAX_N]; ^ paths_sums.cpp:14:17: error: template argument 1 is invalid std::vector<Edge> adj[MAX_N]; ^ paths_sums.cpp:14:17: error: template argument 2 is invalid paths_sums.cpp:14:29: error: invalid type in declaration before ';' token std::vector<Edge> adj[MAX_N]; ^ paths_sums.cpp: In function 'void dfs(int, int)': paths_sums.cpp:23:13: error: 'Edge' does not name a type for(const Edge &e : adj[u]) { ^ paths_sums.cpp:30:3: error: expected ';' before 'tout' tout[u] = time; ^ paths_sums.cpp:30:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses] tout[u] = time; ^ paths_sums.cpp:31:1: error: expected primary-expression before '}' token } ^ paths_sums.cpp:31:1: error: expected ')' before '}' token paths_sums.cpp:31:1: error: expected primary-expression before '}' token paths_sums.cpp:31:1: error: expected ';' before '}' token paths_sums.cpp: In function 'int get_lca(int, int)': paths_sums.cpp:44:18: error: 'MAX_LOG' was not declared in this scope for(int step = MAX_LOG - 1; step >= 0; step--) { ^ paths_sums.cpp:45:21: error: 'up' was not declared in this scope if(!is_ancestor(up[step][u], v)) { ^ paths_sums.cpp:49:10: error: 'up' was not declared in this scope return up[0][u]; ^ paths_sums.cpp: In function 'int main()': paths_sums.cpp:59:5: error: 'up' was not declared in this scope up[0][i] = parent; ^ paths_sums.cpp:60:17: error: request for member 'push_back' in 'adj[parent]', which is of non-class type 'int' adj[parent].push_back({i, cost}); ^ paths_sums.cpp:64:22: error: 'MAX_LOG' was not declared in this scope for(int i = 1; i < MAX_LOG; i++) { ^ paths_sums.cpp:66:7: error: 'up' was not declared in this scope up[i][j] = up[i - 1][up[i - 1][j]]; ^ paths_sums.cpp: In function 'int get_lca(int, int)': paths_sums.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ paths_sums.cpp: In function 'int main()': paths_sums.cpp:54:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &n, &q); ^ paths_sums.cpp:57:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &parent, &cost); ^ paths_sums.cpp:72:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d", &u, &v); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema paths_sums face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.