#674
Se dă un arbore binar care conține valori numere naturale. Se dau k noduri din arbore și se cere determinarea, pentru fiecare nod, a numărului de noduri din subarborele cu rădăcina în acel nod.
Notă: pentru reprezentarea arborelui se recomandă alocarea statică, folosind tablouri.
| Problema | CountSub | Operații I/O |
countsub.in/countsub.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64621276 | Utilizator | |
| Fișier | countsub.cpp | Dimensiune | 646 B |
| Data încărcării | 19 Mai 2026, 08:21 | Scor/rezultat | Eroare de compilare |
countsub.cpp:1:1: error: ‘include’ does not name a type 1 | include<stdio.h> | ^~~~~~~ In file included from /usr/include/c++/13/cmath:45, from /usr/include/c++/13/math.h:36, from countsub.cpp:2: /usr/include/c++/13/ext/type_traits.h:164:35: error: ‘constexpr const bool __gnu_cxx::__is_null_pointer’ redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/13/ext/type_traits.h:159:5: note: previous declaration ‘template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)’ 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/13/ext/type_traits.h:164:26: error: ‘nullptr_t’ is not a member of ‘std’ 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ countsub.cpp:4:1: error: ‘FILE’ does not name a type 4 | FILE*f=fopen("countsub.in","r"); | ^~~~ countsub.cpp:3:1: note: ‘FILE’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’? 2 | #include<math.h> +++ |+#include <cstdio> 3 | int n, st[1001],dr[1001],inf[1001],fr[1001],r; countsub.cpp:5:1: error: ‘FILE’ does not name a type 5 | FILE*g=fopen("countsub.out","w"); | ^~~~ countsub.cpp:5:1: note: ‘FILE’ is defined in header ‘<cstdio>’; did you forget to ‘#include <cstdio>’? countsub.cpp: In function ‘int main()’: countsub.cpp:15:12: error: ‘f’ was not declared in this scope 15 | fscanf(f,"%d",&n); | ^ countsub.cpp:15:5: error: ‘fscanf’ was not declared in this scope; did you mean ‘isnanf’? 15 | fscanf(f,"%d",&n); | ^~~~~~ | isnanf countsub.cpp:27:17: error: ‘g’ was not declared in this scope 27 | fprintf(g,"%d\n",nrnoduri(x)); | ^ countsub.cpp:27:9: error: ‘fprintf’ was not declared in this scope; did you mean ‘rintf’? 27 | fprintf(g,"%d\n",nrnoduri(x)); | ^~~~~~~ | rintf countsub.cpp:29:5: error: ‘fclose’ was not declared in this scope 29 | fclose(f); | ^~~~~~ countsub.cpp:30:12: error: ‘g’ was not declared in this scope 30 | fclose(g); | ^ countsub.cpp:14:9: warning: unused variable ‘r’ [-Wunused-variable] 14 | int r,k; | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema CountSub 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ă.