#647
Se dă vectorul de tați al unui arbore cu rădăcină cu n noduri și un nod k. Fiecare nod al arborelui are asociată o valoare numerică întreagă. Determinați suma valorilor asociate nodurilor din subarborele cu rădăcina în k.
| Problema | Subarbore2 | Operații I/O |
subarbore2.in/subarbore2.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64876334 | Utilizator | |
| Fișier | subarbore2.cpp | Dimensiune | 491 B |
| Data încărcării | 09 Iunie 2026, 08:17 | Scor/rezultat | Eroare de compilare |
subarbore2.cpp:2:7: error: expected nested-name-specifier before ‘namaespace’ 2 | using namaespace std; | ^~~~~~~~~~ subarbore2.cpp: In function ‘void dfs(int)’: subarbore2.cpp:7:13: error: ‘val’ was not declared in this scope 7 | suma += val[k]; | ^~~ subarbore2.cpp:8:25: error: ‘n’ was not declared in this scope 8 | for(int i = 1; i <= n; i++) | ^ subarbore2.cpp:9:12: error: ‘T’ was not declared in this scope 9 | if(T[i] == k) | ^ subarbore2.cpp: In function ‘int main()’: subarbore2.cpp:14:5: error: ‘ifstream’ was not declared in this scope; did you mean ‘std::ifstream’? 14 | ifstream f("subarbore2.in"); | ^~~~~~~~ | std::ifstream In file included from /usr/include/c++/13/ios:40, from /usr/include/c++/13/istream:40, from /usr/include/c++/13/fstream:40, from subarbore2.cpp:1: /usr/include/c++/13/iosfwd:164:41: note: ‘std::ifstream’ declared here 164 | typedef basic_ifstream<char> ifstream; | ^~~~~~~~ subarbore2.cpp:15:5: error: ‘f’ was not declared in this scope 15 | f >> n >> k; | ^ subarbore2.cpp:15:10: error: ‘n’ was not declared in this scope 15 | f >> n >> k; | ^ subarbore2.cpp:15:15: error: ‘k’ was not declared in this scope 15 | f >> n >> k; | ^ subarbore2.cpp:18:14: error: ‘T’ was not declared in this scope 18 | f >> T[i]; | ^ subarbore2.cpp:20:14: error: ‘val’ was not declared in this scope 20 | f >> val[i]; | ^~~ subarbore2.cpp:26:5: error: ‘ofstream’ was not declared in this scope; did you mean ‘std::ofstream’? 26 | ofstream g("subarbore2.out"); | ^~~~~~~~ | std::ofstream /usr/include/c++/13/iosfwd:167:41: note: ‘std::ofstream’ declared here 167 | typedef basic_ofstream<char> ofstream; | ^~~~~~~~ subarbore2.cpp:27:5: error: ‘g’ was not declared in this scope 27 | g << suma; | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Subarbore2 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ă.