#3235
Se consideră un graf care inițial este format din P
noduri izolate, etichetate de la 1
la P
. Se mai consideră N
intrări, unde intrare poate însemna:
I + J
, cu semnificația că în graf se adaugă muchia care unește nodurile I
și J
(dacă I
și J
erau deja unite în acel moment, nu se întreprinde nici o acțiune);I ? J
, adică se întreabă dacă în acel moment I
și J
sunt în aceeași componentă conexă.Se pleacă deci de la un graf inițial format din noduri izolate, care pe parcurs se “unifică”. Tot pe parcurs sunteți întrebat dacă anumite perechi de noduri sunt sau nu în aceeași componentă conexă. Scrieți un program care să răspundă la întrebările din fișierul de intrare.
ONI 2001, clasele XI-XII
Problema | entries | Operații I/O |
![]() entries.in /entries.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 4 MB
/
Stivă 1 MB
|
Id soluție | #56013804 | Utilizator | |
Fișier | entries.cpp | Dimensiune | 2.60 KB |
Data încărcării | 03 Februarie 2025, 10:50 | Scor / rezultat | Eroare de compilare |
entries.cpp: In function 'int main()': entries.cpp:14:5: error: 'fin' was not declared in this scope fin>>n; ^ entries.cpp:15:9: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[0]->value=0; ^ entries.cpp:20:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(x>v.size()) ^ entries.cpp:21:21: error: lvalue required as left operand of assignment v.size()=x; ^ entries.cpp:22:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(y>v.size()) ^ entries.cpp:23:18: error: lvalue required as left operand of assignment v.size()=y; ^ entries.cpp:27:20: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' p=v[x]->rad; ^ entries.cpp:28:20: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' t=v[y]->rad; ^ entries.cpp:29:23: error: request for member 'rad' in '* p', which is of non-class type 'int' while(p->rad!=NULL||p->rad!=v[0]) ^ entries.cpp:29:37: error: request for member 'rad' in '* p', which is of non-class type 'int' while(p->rad!=NULL||p->rad!=v[0]) ^ entries.cpp:30:22: error: request for member 'rad' in '* p', which is of non-class type 'int' p=p->rad; ^ entries.cpp:31:22: error: request for member 'rad' in '* t', which is of non-class type 'int' while(t->rad!=NULL||t->rad!=v[0]) ^ entries.cpp:31:36: error: request for member 'rad' in '* t', which is of non-class type 'int' while(t->rad!=NULL||t->rad!=v[0]) ^ entries.cpp:32:22: error: request for member 'rad' in '* t', which is of non-class type 'int' t=t->rad; ^ entries.cpp:38:16: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' if(v[x]->rad!=v[y]->rad) ^ entries.cpp:38:27: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' if(v[x]->rad!=v[y]->rad) ^ entries.cpp:40:24: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' if(v[x]->rad==NULL) ^ entries.cpp:42:24: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' p=v[y]->rad; ^ entries.cpp:43:22: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[x]->rad=p; ^ entries.cpp:44:22: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[y]->rad->nr++; ^ entries.cpp:47:22: error: base operand of '->' is not a pointer if(y->rad==NULL) ^ entries.cpp:49:24: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' p=v[x]->rad; ^ entries.cpp:50:22: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[y]->rad=p; ^ entries.cpp:51:22: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[x]->rad->nr++; ^ entries.cpp:54:32: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' if(v[x]->rad->nr>v[y]->rad->nr) ^ entries.cpp:54:46: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' if(v[x]->rad->nr>v[y]->rad->nr) ^ entries.cpp:56:34: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[y]->rad->rad=v[x]->rad; ^ entries.cpp:56:49: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[y]->rad->rad=v[x]->rad; ^ entries.cpp:57:34: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[x]->rad->nr+=v[y]->rad->nr; ^ entries.cpp:57:49: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[x]->rad->nr+=v[y]->rad->nr; ^ entries.cpp:58:34: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[y]->rad->nr=v[x]->rad->nr; ^ entries.cpp:58:48: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[y]->rad->nr=v[x]->rad->nr; ^ entries.cpp:63:34: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[x]->rad->rad=v[y]->rad; ^ entries.cpp:63:49: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[x]->rad->rad=v[y]->rad; ^ entries.cpp:64:34: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[y]->rad->nr+=v[x]->rad->nr; ^ entries.cpp:64:49: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[y]->rad->nr+=v[x]->rad->nr; ^ entries.cpp:65:34: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[x]->rad->nr=v[y]->rad->nr; ^ entries.cpp:65:48: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[x]->rad->nr=v[y]->rad->nr; ^ entries.cpp:69:28: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' if(v[x]->rad==NULL&&v[y]->rad==NULL) ^ entries.cpp:69:45: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' if(v[x]->rad==NULL&&v[y]->rad==NULL) ^ entries.cpp:71:29: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[x]->rad=v[0]; ^ entries.cpp:72:29: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[y]->rad=v[x]; ^ entries.cpp:75:32: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' if(v[x]->rad==v[0]&&v[y]->rad==v[0]) ^ entries.cpp:75:49: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' if(v[x]->rad==v[0]&&v[y]->rad==v[0]) ^ entries.cpp:77:37: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' if(v[x]->rad->nr>v[y]->rad->nr) ^ entries.cpp:77:51: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' if(v[x]->rad->nr>v[y]->rad->nr) ^ entries.cpp:79:34: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[y]->rad->rad=v[x]->rad; ^ entries.cpp:79:49: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[y]->rad->rad=v[x]->rad; ^ entries.cpp:80:34: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[x]->rad->nr+=v[y]->rad->nr; ^ entries.cpp:80:49: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[x]->rad->nr+=v[y]->rad->nr; ^ entries.cpp:81:34: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[y]->rad->nr=v[x]->rad->nr; ^ entries.cpp:81:48: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[y]->rad->nr=v[x]->rad->nr; ^ entries.cpp:86:34: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[x]->rad->rad=v[y]->rad; ^ entries.cpp:86:49: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[x]->rad->rad=v[y]->rad; ^ entries.cpp:87:34: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[y]->rad->nr+=v[x]->rad->nr; ^ entries.cpp:87:49: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[y]->rad->nr+=v[x]->rad->nr; ^ entries.cpp:88:34: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[x]->rad->nr=v[y]->rad->nr; ^ entries.cpp:88:48: error: base operand of '->' has non-pointer type '__gnu_cxx::__alloc_traits<std::allocator<arb> >::value_type {aka arb}' v[x]->rad->nr=v[y]->rad->nr; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema entries 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ă.