#1855
Heap
Se consideră o colecție de numere naturale, inițial vidă. Asupra ei se fac două tipuri de operații:
1 x
– valoarea x
se adaugă în colecție;2
– cea mai mare valoare din colecție se afișează, apoi se elimină din colecție.Dându-se un șir de m
operații, să se afișeze în ordine rezultatele operațiilor de tip 2
.
Problema | Heap | Operații I/O |
heap.in /heap.out
|
---|---|---|---|
Limita timp | 0.3 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #9701492 | Utilizator | |
Fișier | heap.c | Dimensiune | 1.73 KB |
Data încărcării | 23 Mai 2018, 16:14 | Scor / rezultat | 100 puncte |
heap.c: In function 'add': heap.c:27:5: warning: implicit declaration of function 'up' [-Wimplicit-function-declaration] up(h, pos); ^ heap.c: In function 'extract': heap.c:34:5: warning: implicit declaration of function 'down' [-Wimplicit-function-declaration] down(h, 1); ^ heap.c: At top level: heap.c:38:6: warning: conflicting types for 'down' [enabled by default] void down(Heap *h, int pos) ^ heap.c:34:5: note: previous implicit declaration of 'down' was here down(h, 1); ^ heap.c: In function 'down': heap.c:51:13: warning: implicit declaration of function 'swap' [-Wimplicit-function-declaration] swap(h->a+pos, h->a+mc); ^ heap.c: At top level: heap.c:56:6: warning: conflicting types for 'up' [enabled by default] void up(Heap *h, int pos) ^ heap.c:27:5: note: previous implicit declaration of 'up' was here up(h, pos); ^ heap.c:65:6: warning: conflicting types for 'swap' [enabled by default] void swap(Node *a, Node *b) ^ heap.c:51:13: note: previous implicit declaration of 'swap' was here swap(h->a+pos, h->a+mc); ^ heap.c: In function 'main': heap.c:80:11: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result] fscanf(fpin, "%d", &instr); ^ heap.c:83:15: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result] fscanf(fpin, "%d", &com); ^ heap.c:85:16: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result] fscanf(fpin, "%d", &nr); ^
Test | Timp | Mesaj evaluare | Scor posibil | Scor obținut | ||
---|---|---|---|---|---|---|
1 | 0 secunde | OK. | 20 | 20 | Exemplu | |
2 | 0 secunde | OK. | 20 | 20 | ||
3 | 0.008 secunde | OK. | 20 | 20 | ||
4 | 0.064 secunde | OK. | 20 | 20 | ||
5 | 0.064 secunde | OK. | 20 | 20 | ||
Punctaj total | 100 |
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Heap 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ă.