#2510
Considerăm un șir de numere naturale nenule a[1], a[2], …, a[n]. În acest șir o V-secvență este o secvență maximală de forma a[x], a[x+1], …, a[y] cu proprietatea că toate numerele din secvență au valori mai mici sau egale cu V. Este maximală pentru că nu poate fi extinsă spre stânga sau spre dreapta. De exemplu, șirul a = 2, 2, 6, 4, 3, 14, 7, 4, 3, 36 are două 7-secvențe: 2, 2, 6, 4, 3 și 7, 4, 3. De asemenea, șirul are trei 4-secvențe: 2,2; 4,3; 4,3. De notat că 2,6,4,3 nu este 7-secvență, deoarece poate fi extinsă la capătul său stâng cu numărul 2.
Pentru un șir de numere dat, trebuie să răspundeți la Q întrebări notate V[1], V[2],…, V[Q]. Pentru fiecare întrebare i, dată prin numărul natural V[i], trebuie să aflați câte V[i]-secvențe sunt în șir.
Lot juniori Câmpulung Muscel, 2018
| Problema | vsecvente | Operații I/O |
vsecvente.in/vsecvente.out
|
|---|---|---|---|
| Limita timp | 0.3 secunde | Limita memorie |
Total: 8 MB
/
Stivă 8 MB
|
| Id soluție | #58905367 | Utilizator | |
| Fișier | vsecvente.cpp | Dimensiune | 1.75 KB |
| Data încărcării | 31 August 2025, 21:36 | Scor/rezultat | Eroare de compilare |
In file included from /usr/include/c++/4.8/algorithm:62:0, from vsecvente.cpp:2: /usr/include/c++/4.8/bits/stl_algo.h: In instantiation of '_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, _Compare) [with _RandomAccessIterator = nod*; _Tp = nod; _Compare = Sortare]': /usr/include/c++/4.8/bits/stl_algo.h:2296:78: required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = nod*; _Compare = Sortare]' /usr/include/c++/4.8/bits/stl_algo.h:2337:62: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = nod*; _Size = int; _Compare = Sortare]' /usr/include/c++/4.8/bits/stl_algo.h:5499:44: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = nod*; _Compare = Sortare]' vsecvente.cpp:49:29: required from here /usr/include/c++/4.8/bits/stl_algo.h:2263:35: error: no match for call to '(Sortare) (nod&, const nod&)' while (__comp(*__first, __pivot)) ^ vsecvente.cpp:13:7: note: candidate is: class Sortare{ ^ vsecvente.cpp:15:10: note: bool Sortare::operator()(nod&, nod&) bool operator()(nod &x, nod&y){ ^ vsecvente.cpp:15:10: note: no known conversion for argument 2 from 'const nod' to 'nod&' In file included from /usr/include/c++/4.8/algorithm:62:0, from vsecvente.cpp:2: /usr/include/c++/4.8/bits/stl_algo.h:2266:34: error: no match for call to '(Sortare) (const nod&, nod&)' while (__comp(__pivot, *__last)) ^ vsecvente.cpp:13:7: note: candidate is: class Sortare{ ^ vsecvente.cpp:15:10: note: bool Sortare::operator()(nod&, nod&) bool operator()(nod &x, nod&y){ ^ vsecvente.cpp:15:10: note: no known conversion for argument 1 from 'const nod' to 'nod&' In file included from /usr/include/c++/4.8/algorithm:62:0, from vsecvente.cpp:2: /usr/include/c++/4.8/bits/stl_algo.h: In instantiation of '_RandomAccessIterator std::__unguarded_partition(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, _Compare) [with _RandomAccessIterator = nod*; _Tp = nod; _Compare = Sortare1]': /usr/include/c++/4.8/bits/stl_algo.h:2296:78: required from '_RandomAccessIterator std::__unguarded_partition_pivot(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = nod*; _Compare = Sortare1]' /usr/include/c++/4.8/bits/stl_algo.h:2337:62: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = nod*; _Size = int; _Compare = Sortare1]' /usr/include/c++/4.8/bits/stl_algo.h:5499:44: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = nod*; _Compare = Sortare1]' vsecvente.cpp:75:30: required from here /usr/include/c++/4.8/bits/stl_algo.h:2263:35: error: no match for call to '(Sortare1) (nod&, const nod&)' while (__comp(*__first, __pivot)) ^ vsecvente.cpp:21:7: note: candidate is: class Sortare1{ ^ vsecvente.cpp:23:10: note: bool Sortare1::operator()(nod&, nod&) bool operator()(nod &x, nod&y){ ^ vsecvente.cpp:23:10: note: no known conversion for argument 2 from 'const nod' to 'nod&' In file included from /usr/include/c++/4.8/algorithm:62:0, from vsecvente.cpp:2: /usr/include/c++/4.8/bits/stl_algo.h:2266:34: error: no match for call to '(Sortare1) (const nod&, nod&)' while (__comp(__pivot, *__last)) ^ vsecvente.cpp:21:7: note: candidate is: class Sortare1{ ^ vsecvente.cpp:23:10: note: bool Sortare1::operator()(nod&, nod&) bool operator()(nod &x, nod&y){ ^ vsecvente.cpp:23:10: note: no known conversion for argument 1 from 'const nod' to 'nod&'
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema vsecvente 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ă.