#2454
Fie un vector v
sortat crescător cu N
elemente naturale nenule distincte pe care nu le cunoaştem, dar pe care ne propunem să le determinăm. Având la dispoziţie acest vector v
, cu ajutorul următorului algoritm de căutare binară putem răspunde la queryuri de forma: Dându-se un număr X
şi un interval [a, b]
se cere să se determine cel mai mic element mai mare decât X
aflat în intervalul determinat de indicii a
şi b
, interval din vectorul v
. Se cunosc paşii pe care algoritmul de cautare binară i-a urmat pentru diferite valori ale tripletului (X, a, b)
.
Dându-se N
(lungimea vectorului), Q
(numărul de query-uri apelate) şi cele Q
query-uri, să se determine vectorul iniţial. Dacă există mai multe soluţii se va afişa soluţia minim lexicografică. Dacă nu există soluţie se va afişa valoarea -1
.
ONI 2018 clasa a IX-a
Problema | bsrec | Operații I/O |
![]() bsrec.in /bsrec.out
|
---|---|---|---|
Limita timp | 0.3 secunde | Limita memorie |
Total: 128 MB
/
Stivă 32 MB
|
Id soluție | #12636687 | Utilizator | |
Fișier | bsrec.cpp | Dimensiune | 1.29 KB |
Data încărcării | 07 Decembrie 2018, 18:44 | Scor / rezultat | 0 puncte |
bsrec.cpp: In function 'int main()': bsrec.cpp:9:18: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long int*' [-Wformat=] scanf("%d",&t); ^ bsrec.cpp:12:28: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long int*' [-Wformat=] scanf("%d %d",&n,&q); ^ bsrec.cpp:12:28: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long int*' [-Wformat=] bsrec.cpp:15:32: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long int*' [-Wformat=] scanf("%d %d",&x,&m); ^ bsrec.cpp:15:32: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long int*' [-Wformat=] bsrec.cpp:16:32: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long int*' [-Wformat=] scanf("%d %d",&a,&b); ^ bsrec.cpp:16:32: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long int*' [-Wformat=] bsrec.cpp:19:38: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long int*' [-Wformat=] scanf("%d %d",&st,&dr); ^ bsrec.cpp:19:38: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long int*' [-Wformat=] bsrec.cpp:7:34: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result] freopen("bsrec.in","r",stdin); ^ bsrec.cpp:8:36: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result] freopen("bsrec.out","w",stdout); ^ bsrec.cpp:9:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&t); ^ bsrec.cpp:12:29: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d",&n,&q); ^ bsrec.cpp:15:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d",&x,&m); ^ bsrec.cpp:16:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d",&a,&b); ^ bsrec.cpp:19:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d",&st,&dr); ^
Test | Timp | Mesaj evaluare | Scor posibil | Scor obținut | ||
---|---|---|---|---|---|---|
0 | 0 secunde | Raspuns gresit. | 10 | 0 | ||
1 | 0 secunde | Raspuns gresit. | 10 | 0 | ||
2 | 0 secunde | Raspuns gresit. | 10 | 0 | ||
3 | 0 secunde | Raspuns gresit. | 10 | 0 | ||
4 | 0 secunde | Raspuns gresit. | 10 | 0 | ||
5 | 0.012 secunde | Raspuns gresit. | 10 | 0 | ||
6 | 0.012 secunde | Raspuns gresit. | 10 | 0 | ||
7 | 0.012 secunde | Raspuns gresit. | 10 | 0 | ||
8 | 0.012 secunde | Raspuns gresit. | 10 | 0 | ||
9 | 0.012 secunde | Raspuns gresit. | 10 | 0 | ||
Punctaj total | 0 |
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema bsrec 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ă.