#4145
CFR
C++
RAU-Gigel se joacă cu noul său set de cale ferată, primit cadou de ziua lui anul acesta. Setul conține N
gări distincte din diverse orașe reprezentative ale României (București, Iași, Sebeș, …), numerotate în continuare, pentru simplitate, cu numere de la 1
la N
și N – 1
bucăți de șină care pot conecta între ele câte două gări distincte date (conexiunea este bidirecțională) astfel încât folosind aceste șine există un drum unic alcătuit din șine între oricare două gări distincte. Ca orice jucărie, fiecare din cele N – 1
bucăți de șină are un grad de periculozitate asociat acesteia, o valoare exprimată printr-un număr natural nenul (nimeni nu este perfect până la urmă, nici jucăriile), pentru a ști de la ce vârsta ar fi bine să poată fi folosite de copii, de exemplu. De asemenea, toate bucățile de șină au aceeași lungime constantă, de o unitate.
RAU-Gigel își desfășoară joaca pe parcursul a Q
zile și în fiecare zi este supravegheat de câte un membru al familiei pentru a fi în siguranță. Din nefericire pentru el, în fiecare din cele Q
zile persoana care îl supraveghează îi încurcă puțin planurile, permițându-i să folosească doar șinele care au gradul de periculozitate cel mult M
(inclusiv M
), o valoare naturală nenulă aleasă de aceasta (de remarcat că poate mereu folosi toate gările). Astfel, folosind toate șinele pe care le are la dispoziție pentru a conecta între ele gările corespunzătoare, va obține una sau mai multe așezări conexe maximale de gări (există un drum unic alcătuit din șine între oricare două gări distincte dintr-o așezare) pe care le va numi în continuare orașe. În fiecare astfel de zi, personajul nostru principal primește de la persoana care îl supraveghează un număr natural nenul K
de bucăți de șină considerate perfect sigure pentru joaca copilului de către respectivul supraveghetor, cu care poate conecta oricare două gări distincte dorește. De asemenea, șinele primite îi sunt luate la finalul zilei (poate că persoana respectivă mai supraveghează și alți copii în următoarele zile și mai are nevoie de ele).
RAU-Gigel consideră că un lanț este un șir de una sau mai multe gări distincte astfel încât oricare două gări adiacente din acesta sunt conectate de exact o șină, iar lanțul de lungime maximă este cel format dintr-un număr maxim de bucăți de șină (astfel, lungimea unui lanț este dată de numărul de bucăți de șină din care este alcătuit). Scopul acestuia este ca în fiecare zi să formeze un singur lanț cât mai lung având la dispoziție șinele primite de la supraveghetor și cel mult câte un lanț din fiecare oraș creat de acesta, la alegere (adică pentru fiecare oraș poate să aleagă exact un lanț din el (oricare dorește) sau să nu folosească niciun lanț din acel oraș).
RAU-Coder 2022
Problema | CFR | Operații I/O |
cfr.in /cfr.out
|
---|---|---|---|
Limita timp | 1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #43594454 | Utilizator | |
Fișier | cfr.cpp | Dimensiune | 5.08 KB |
Data încărcării | 04 Mai 2023, 23:05 | Scor / rezultat | Eroare de compilare |
cfr.cpp: In member function 'AINT::node AINT::update(int, int, int, int, int)': cfr.cpp:61:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses] int m=(st+dr>>1); ^ cfr.cpp: In member function 'void AINT::query(int, int, int)': cfr.cpp:74:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses] int m=(st+dr>>1); ^ cfr.cpp: In function 'void solve()': cfr.cpp:130:24: error: 'query' is not a type sort(all(query),[](query a,query b){return a.val<b.val;}); ^ cfr.cpp:130:32: error: 'query' is not a type sort(all(query),[](query a,query b){return a.val<b.val;}); ^ cfr.cpp: In lambda function: cfr.cpp:130:50: error: request for member 'val' in 'a', which is of non-class type 'int' sort(all(query),[](query a,query b){return a.val<b.val;}); ^ cfr.cpp:130:56: error: request for member 'val' in 'b', which is of non-class type 'int' sort(all(query),[](query a,query b){return a.val<b.val;}); ^ cfr.cpp: At global scope: cfr.cpp:230:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] main() ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h: In instantiation of 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Compare = solve()::__lambda1]': /usr/include/c++/4.8/bits/stl_algo.h:2226:70: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Compare = solve()::__lambda1]' /usr/include/c++/4.8/bits/stl_algo.h:5500:55: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Compare = solve()::__lambda1]' cfr.cpp:130:61: required from here /usr/include/c++/4.8/bits/stl_algo.h:2159:29: error: no match for call to '(solve()::__lambda1) (trio&, trio&)' if (__comp(*__i, *__first)) ^ cfr.cpp:130:22: note: candidates are: sort(all(query),[](query a,query b){return a.val<b.val;}); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h:2159:29: note: void (*)(int, int) <conversion> if (__comp(*__i, *__first)) ^ /usr/include/c++/4.8/bits/stl_algo.h:2159:29: note: candidate expects 3 arguments, 3 provided cfr.cpp:130:39: note: solve()::__lambda1 sort(all(query),[](query a,query b){return a.val<b.val;}); ^ cfr.cpp:130:39: note: no known conversion for argument 1 from 'trio' to 'int' In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h: In instantiation of 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Compare = solve()::__lambda1]': /usr/include/c++/4.8/bits/stl_algo.h:5349:59: required from 'void std::partial_sort(_RAIter, _RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Compare = solve()::__lambda1]' /usr/include/c++/4.8/bits/stl_algo.h:2332:68: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Size = int; _Compare = solve()::__lambda1]' /usr/include/c++/4.8/bits/stl_algo.h:5499:44: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Compare = solve()::__lambda1]' cfr.cpp:130:61: required from here /usr/include/c++/4.8/bits/stl_algo.h:1948:27: error: no match for call to '(solve()::__lambda1) (trio&, trio&)' if (__comp(*__i, *__first)) ^ cfr.cpp:130:22: note: candidates are: sort(all(query),[](query a,query b){return a.val<b.val;}); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h:1948:27: note: void (*)(int, int) <conversion> if (__comp(*__i, *__first)) ^ /usr/include/c++/4.8/bits/stl_algo.h:1948:27: note: candidate expects 3 arguments, 3 provided cfr.cpp:130:39: note: solve()::__lambda1 sort(all(query),[](query a,query b){return a.val<b.val;}); ^ cfr.cpp:130:39: note: no known conversion for argument 1 from 'trio' to 'int' In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h: In instantiation of 'void std::__move_median_to_first(_Iterator, _Iterator, _Iterator, _Iterator, _Compare) [with _Iterator = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Compare = solve()::__lambda1]': /usr/include/c++/4.8/bits/stl_algo.h:2295:13: required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Compare = solve()::__lambda1]' /usr/include/c++/4.8/bits/stl_algo.h:2337:62: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Size = int; _Compare = solve()::__lambda1]' /usr/include/c++/4.8/bits/stl_algo.h:5499:44: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Compare = solve()::__lambda1]' cfr.cpp:130:61: required from here /usr/include/c++/4.8/bits/stl_algo.h:114:28: error: no match for call to '(solve()::__lambda1) (trio&, trio&)' if (__comp(*__a, *__b)) ^ cfr.cpp:130:22: note: candidates are: sort(all(query),[](query a,query b){return a.val<b.val;}); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h:114:28: note: void (*)(int, int) <conversion> if (__comp(*__a, *__b)) ^ /usr/include/c++/4.8/bits/stl_algo.h:114:28: note: candidate expects 3 arguments, 3 provided cfr.cpp:130:39: note: solve()::__lambda1 sort(all(query),[](query a,query b){return a.val<b.val;}); ^ cfr.cpp:130:39: note: no known conversion for argument 1 from 'trio' to 'int' In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h:116:25: error: no match for call to '(solve()::__lambda1) (trio&, trio&)' if (__comp(*__b, *__c)) ^ cfr.cpp:130:22: note: candidates are: sort(all(query),[](query a,query b){return a.val<b.val;}); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h:116:25: note: void (*)(int, int) <conversion> if (__comp(*__b, *__c)) ^ /usr/include/c++/4.8/bits/stl_algo.h:116:25: note: candidate expects 3 arguments, 3 provided cfr.cpp:130:39: note: solve()::__lambda1 sort(all(query),[](query a,query b){return a.val<b.val;}); ^ cfr.cpp:130:39: note: no known conversion for argument 1 from 'trio' to 'int' In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h:118:30: error: no match for call to '(solve()::__lambda1) (trio&, trio&)' else if (__comp(*__a, *__c)) ^ cfr.cpp:130:22: note: candidates are: sort(all(query),[](query a,query b){return a.val<b.val;}); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h:118:30: note: void (*)(int, int) <conversion> else if (__comp(*__a, *__c)) ^ /usr/include/c++/4.8/bits/stl_algo.h:118:30: note: candidate expects 3 arguments, 3 provided cfr.cpp:130:39: note: solve()::__lambda1 sort(all(query),[](query a,query b){return a.val<b.val;}); ^ cfr.cpp:130:39: note: no known conversion for argument 1 from 'trio' to 'int' In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h:123:33: error: no match for call to '(solve()::__lambda1) (trio&, trio&)' else if (__comp(*__a, *__c)) ^ cfr.cpp:130:22: note: candidates are: sort(all(query),[](query a,query b){return a.val<b.val;}); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h:123:33: note: void (*)(int, int) <conversion> else if (__comp(*__a, *__c)) ^ /usr/include/c++/4.8/bits/stl_algo.h:123:33: note: candidate expects 3 arguments, 3 provided cfr.cpp:130:39: note: solve()::__lambda1 sort(all(query),[](query a,query b){return a.val<b.val;}); ^ cfr.cpp:130:39: note: no known conversion for argument 1 from 'trio' to 'int' In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h:125:33: error: no match for call to '(solve()::__lambda1) (trio&, trio&)' else if (__comp(*__b, *__c)) ^ cfr.cpp:130:22: note: candidates are: sort(all(query),[](query a,query b){return a.val<b.val;}); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h:125:33: note: void (*)(int, int) <conversion> else if (__comp(*__b, *__c)) ^ /usr/include/c++/4.8/bits/stl_algo.h:125:33: note: candidate expects 3 arguments, 3 provided cfr.cpp:130:39: note: solve()::__lambda1 sort(all(query),[](query a,query b){return a.val<b.val;}); ^ cfr.cpp:130:39: note: no known conversion for argument 1 from 'trio' to 'int' In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h: In instantiation of '_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Tp = trio; _Compare = solve()::__lambda1]': /usr/include/c++/4.8/bits/stl_algo.h:2296:78: required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Compare = solve()::__lambda1]' /usr/include/c++/4.8/bits/stl_algo.h:2337:62: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Size = int; _Compare = solve()::__lambda1]' /usr/include/c++/4.8/bits/stl_algo.h:5499:44: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Compare = solve()::__lambda1]' cfr.cpp:130:61: required from here /usr/include/c++/4.8/bits/stl_algo.h:2263:35: error: no match for call to '(solve()::__lambda1) (trio&, const trio&)' while (__comp(*__first, __pivot)) ^ cfr.cpp:130:22: note: candidates are: sort(all(query),[](query a,query b){return a.val<b.val;}); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h:2263:35: note: void (*)(int, int) <conversion> while (__comp(*__first, __pivot)) ^ /usr/include/c++/4.8/bits/stl_algo.h:2263:35: note: candidate expects 3 arguments, 3 provided cfr.cpp:130:39: note: solve()::__lambda1 sort(all(query),[](query a,query b){return a.val<b.val;}); ^ cfr.cpp:130:39: note: no known conversion for argument 1 from 'trio' to 'int' In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h:2266:34: error: no match for call to '(solve()::__lambda1) (const trio&, trio&)' while (__comp(__pivot, *__last)) ^ cfr.cpp:130:22: note: candidates are: sort(all(query),[](query a,query b){return a.val<b.val;}); ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h:2266:34: note: void (*)(int, int) <conversion> while (__comp(__pivot, *__last)) ^ /usr/include/c++/4.8/bits/stl_algo.h:2266:34: note: candidate expects 3 arguments, 3 provided cfr.cpp:130:39: note: solve()::__lambda1 sort(all(query),[](query a,query b){return a.val<b.val;}); ^ cfr.cpp:130:39: note: no known conversion for argument 1 from 'const trio' to 'int' In file included from /usr/include/c++/4.8/queue:62:0, from cfr.cpp:3: /usr/include/c++/4.8/bits/stl_heap.h: In instantiation of 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Distance = int; _Tp = trio; _Compare = solve()::__lambda1]': /usr/include/c++/4.8/bits/stl_heap.h:448:15: required from 'void std::make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Compare = solve()::__lambda1]' /usr/include/c++/4.8/bits/stl_algo.h:1946:47: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Compare = solve()::__lambda1]' /usr/include/c++/4.8/bits/stl_algo.h:5349:59: required from 'void std::partial_sort(_RAIter, _RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Compare = solve()::__lambda1]' /usr/include/c++/4.8/bits/stl_algo.h:2332:68: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Size = int; _Compare = solve()::__lambda1]' /usr/include/c++/4.8/bits/stl_algo.h:5499:44: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Compare = solve()::__lambda1]' cfr.cpp:130:61: required from here /usr/include/c++/4.8/bits/stl_heap.h:313:40: error: no match for call to '(solve()::__lambda1) (trio&, trio&)' *(__first + (__secondChild - 1)))) ^ cfr.cpp:130:22: note: candidates are: sort(all(query),[](query a,query b){return a.val<b.val;}); ^ In file included from /usr/include/c++/4.8/queue:62:0, from cfr.cpp:3: /usr/include/c++/4.8/bits/stl_heap.h:313:40: note: void (*)(int, int) <conversion> *(__first + (__secondChild - 1)))) ^ /usr/include/c++/4.8/bits/stl_heap.h:313:40: note: candidate expects 3 arguments, 3 provided cfr.cpp:130:39: note: solve()::__lambda1 sort(all(query),[](query a,query b){return a.val<b.val;}); ^ cfr.cpp:130:39: note: no known conversion for argument 1 from 'trio' to 'int' In file included from /usr/include/c++/4.8/algorithm:62:0, from cfr.cpp:7: /usr/include/c++/4.8/bits/stl_algo.h:2110:5: error: 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Compare = solve()::__lambda1]', declared using local type 'solve()::__lambda1', is used but never defined [-fpermissive] __unguarded_linear_insert(_RandomAccessIterator __last, ^ In file included from /usr/include/c++/4.8/queue:62:0, from cfr.cpp:3: /usr/include/c++/4.8/bits/stl_heap.h:331:5: error: 'void std::__pop_heap(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Compare = solve()::__lambda1]', declared using local type 'solve()::__lambda1', is used but never defined [-fpermissive] __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, ^ /usr/include/c++/4.8/bits/stl_heap.h:178:5: error: 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<trio*, std::vector<trio> >; _Distance = int; _Tp = trio; _Compare = solve()::__lambda1]', declared using local type 'solve()::__lambda1', is used but never defined [-fpermissive] __push_heap(_RandomAccessIterator __first, _Distance __holeIndex, ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema CFR 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ă.