#641
Subarbore
Se dă vectorul de tați al unui arbore cu rădăcină cu n
noduri și un nod k
. Afișați, în ordine crescătoare, nodurile din subarborele cu rădăcina în k
.
Problema | Subarbore | Operații I/O |
![]() subarbore.in /subarbore.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #28748656 | Utilizator | |
Fișier | subarbore.cpp | Dimensiune | 664 B |
Data încărcării | 17 Martie 2021, 08:39 | Scor / rezultat | Eroare de compilare |
subarbore.cpp:4:13: error: variable 'std::ifstream cin' has initializer but incomplete type ifstream cin("subarbore.in"); ^ subarbore.cpp:6:14: error: variable 'std::ofstream cout' has initializer but incomplete type ofstream cout("subarbore.out"); ^ subarbore.cpp:8:1: error: 'vector' does not name a type vector <int> G[101]; ^ subarbore.cpp:13:1: error: 'vector' does not name a type vector <int> G[101]; ^ subarbore.cpp:15:5: error: redefinition of 'int n' int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp:10:5: error: 'int n' previously declared here int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp:15:9: error: redefinition of 'int p' int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp:10:9: error: 'int p' previously declared here int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp:15:13: error: redefinition of 'int x' int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp:10:13: error: 'int x' previously declared here int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp:15:17: error: redefinition of 'int y' int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp:10:17: error: 'int y' previously declared here int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp:15:21: error: redefinition of 'int k' int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp:10:21: error: 'int k' previously declared here int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp:15:30: error: redefinition of 'int T [102]' int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp:10:25: error: 'int T [102]' previously declared here int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp:15:39: error: redefinition of 'int P [101]' int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp:10:34: error: 'int P [101]' previously declared here int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp:15:50: error: redefinition of 'int rez [101]' int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp:10:43: error: 'int rez [101]' previously declared here int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp:15:54: error: redefinition of 'int cnt' int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp:10:54: error: 'int cnt' previously declared here int n , p , x , y , k , T[102] , P[101] , rez[101] , cnt; ^ subarbore.cpp: In function 'void dfs(int)': subarbore.cpp:26:12: error: 'G' was not declared in this scope for(auto i:G[x]) ^ subarbore.cpp: In function 'int main()': subarbore.cpp:37:1: error: reference to 'cin' is ambiguous cin >> n >> p; ^ subarbore.cpp:4:10: note: candidates are: <typeprefixerror>cin ifstream cin("subarbore.in"); ^ In file included from subarbore.cpp:1:0: /usr/include/c++/4.8/iostream:60:18: note: std::istream std::cin extern istream cin; /// Linked to standard input ^ subarbore.cpp:43:1: error: reference to 'cin' is ambiguous cin >> T[i]; ^ subarbore.cpp:4:10: note: candidates are: <typeprefixerror>cin ifstream cin("subarbore.in"); ^ In file included from subarbore.cpp:1:0: /usr/include/c++/4.8/iostream:60:18: note: std::istream std::cin extern istream cin; /// Linked to standard input ^ subarbore.cpp:47:1: error: 'G' was not declared in this scope G[T[i]].push_back(i); ^ subarbore.cpp:53:29: error: 'sort' was not declared in this scope sort(rez + 1 , rez + cnt + 1); ^ subarbore.cpp:58:1: error: reference to 'cout' is ambiguous cout << rez[i] << " "; ^ subarbore.cpp:6:10: note: candidates are: <typeprefixerror>cout ofstream cout("subarbore.out"); ^ In file included from subarbore.cpp:1:0: /usr/include/c++/4.8/iostream:61:18: note: std::ostream std::cout extern ostream cout; /// Linked to standard output ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Subarbore 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ă.