#2862
stiva2
Să considerăm o stivă, inițial vidă. Putem efectua următoarele operații:
push(X)
– se introduce în stivă litera X
(evident, în vârful stivei);
pop
– se extrage litera aflată la vârful stivei (operația pop se execută atunci când stiva este nevidă);
top
– se afișează litera aflată la vârful stivei (operația top se execută atunci când stiva este nevidă).
O secvență de operații este considerată corectă dacă:
- inițial stiva este vidă;
- se execută o serie de operații push
, pop
, top
, fără a executa pop
sau top
când stiva este vidă;
- la final stiva este vidă.
Utilizând secvențe corecte de operații, putem afișa diferite șiruri de caractere.
Dat fiind un șir format din litere mari, să se determine numărul minim de operații dintr-o secvență corecte care afișează șirul dat.
ONI 2008 Baraj
Problema | stiva2 | Operații I/O |
stiva2.in /stiva2.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #40463023 | Utilizator | |
Fișier | stiva2.cpp | Dimensiune | 1.64 KB |
Data încărcării | 09 Decembrie 2022, 15:59 | Scor / rezultat | Eroare de compilare |
stiva2.cpp:15:1: error: expected ';' after struct definition } ^ stiva2.cpp: In function 'int bine(int, int)': stiva2.cpp:19:13: error: request for member 'tip' in 'v[j]', which is of non-class type 'int' if(v[j].tip==0&&v[i].tip==0) ^ stiva2.cpp:19:26: error: request for member 'tip' in 'v[i]', which is of non-class type 'int' if(v[j].tip==0&&v[i].tip==0) ^ stiva2.cpp:20:16: error: expected ')' before 'x1' if(v[j]x1>=v[i].x1&&v[j].x2<=v[i].x2&&v[j].y1<=v[i].y1&&v[j].y2>=v[i].y2) ^ stiva2.cpp:19:7: warning: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses] if(v[j].tip==0&&v[i].tip==0) ^ stiva2.cpp:23:13: error: request for member 'tip' in 'v[j]', which is of non-class type 'int' if(v[j].tip==1&&v[i].tip==0) ^ stiva2.cpp:23:26: error: request for member 'tip' in 'v[i]', which is of non-class type 'int' if(v[j].tip==1&&v[i].tip==0) ^ stiva2.cpp:24:17: error: request for member 'x1' in 'v[i]', which is of non-class type 'int' if(v[i].x1<=v[j].x1-v[j].x2&&v[i].x2>=v[j].x1+v[j].x2&&v[i].y1>=v[j].y1+v[j].x2&&v[j].y2<=v[j].y1-v[j].x2) ^ stiva2.cpp:24:26: error: request for member 'x1' in 'v[j]', which is of non-class type 'int' if(v[i].x1<=v[j].x1-v[j].x2&&v[i].x2>=v[j].x1+v[j].x2&&v[i].y1>=v[j].y1+v[j].x2&&v[j].y2<=v[j].y1-v[j].x2) ^ stiva2.cpp:24:34: error: request for member 'x2' in 'v[j]', which is of non-class type 'int' if(v[i].x1<=v[j].x1-v[j].x2&&v[i].x2>=v[j].x1+v[j].x2&&v[i].y1>=v[j].y1+v[j].x2&&v[j].y2<=v[j].y1-v[j].x2) ^ stiva2.cpp:24:43: error: request for member 'x2' in 'v[i]', which is of non-class type 'int' if(v[i].x1<=v[j].x1-v[j].x2&&v[i].x2>=v[j].x1+v[j].x2&&v[i].y1>=v[j].y1+v[j].x2&&v[j].y2<=v[j].y1-v[j].x2) ^ stiva2.cpp:24:52: error: request for member 'x1' in 'v[j]', which is of non-class type 'int' if(v[i].x1<=v[j].x1-v[j].x2&&v[i].x2>=v[j].x1+v[j].x2&&v[i].y1>=v[j].y1+v[j].x2&&v[j].y2<=v[j].y1-v[j].x2) ^ stiva2.cpp:24:60: error: request for member 'x2' in 'v[j]', which is of non-class type 'int' if(v[i].x1<=v[j].x1-v[j].x2&&v[i].x2>=v[j].x1+v[j].x2&&v[i].y1>=v[j].y1+v[j].x2&&v[j].y2<=v[j].y1-v[j].x2) ^ stiva2.cpp:24:69: error: request for member 'y1' in 'v[i]', which is of non-class type 'int' if(v[i].x1<=v[j].x1-v[j].x2&&v[i].x2>=v[j].x1+v[j].x2&&v[i].y1>=v[j].y1+v[j].x2&&v[j].y2<=v[j].y1-v[j].x2) ^ stiva2.cpp:24:78: error: request for member 'y1' in 'v[j]', which is of non-class type 'int' if(v[i].x1<=v[j].x1-v[j].x2&&v[i].x2>=v[j].x1+v[j].x2&&v[i].y1>=v[j].y1+v[j].x2&&v[j].y2<=v[j].y1-v[j].x2) ^ stiva2.cpp:24:86: error: request for member 'x2' in 'v[j]', which is of non-class type 'int' if(v[i].x1<=v[j].x1-v[j].x2&&v[i].x2>=v[j].x1+v[j].x2&&v[i].y1>=v[j].y1+v[j].x2&&v[j].y2<=v[j].y1-v[j].x2) ^ stiva2.cpp:24:95: error: request for member 'y2' in 'v[j]', which is of non-class type 'int' if(v[i].x1<=v[j].x1-v[j].x2&&v[i].x2>=v[j].x1+v[j].x2&&v[i].y1>=v[j].y1+v[j].x2&&v[j].y2<=v[j].y1-v[j].x2) ^ stiva2.cpp:24:104: error: request for member 'y1' in 'v[j]', which is of non-class type 'int' if(v[i].x1<=v[j].x1-v[j].x2&&v[i].x2>=v[j].x1+v[j].x2&&v[i].y1>=v[j].y1+v[j].x2&&v[j].y2<=v[j].y1-v[j].x2) ^ stiva2.cpp:24:112: error: request for member 'x2' in 'v[j]', which is of non-class type 'int' if(v[i].x1<=v[j].x1-v[j].x2&&v[i].x2>=v[j].x1+v[j].x2&&v[i].y1>=v[j].y1+v[j].x2&&v[j].y2<=v[j].y1-v[j].x2) ^ stiva2.cpp:23:7: warning: suggest explicit braces to avoid ambiguous 'else' [-Wparentheses] if(v[j].tip==1&&v[i].tip==0) ^ stiva2.cpp:27:13: error: request for member 'tip' in 'v[j]', which is of non-class type 'int' if(v[j].tip==1&&v[i].tip==1) ^ stiva2.cpp:27:26: error: request for member 'tip' in 'v[i]', which is of non-class type 'int' if(v[j].tip==1&&v[i].tip==1) ^ stiva2.cpp:29:13: error: 'd' was not declared in this scope d=sqrt((v[i].x1-v[j].x1)*(v[i].x1-v[j].x1)+(v[i].y1-v[j].y1)*(v[i].y1-v[j].y1)) ^ stiva2.cpp:29:26: error: request for member 'x1' in 'v[i]', which is of non-class type 'int' d=sqrt((v[i].x1-v[j].x1)*(v[i].x1-v[j].x1)+(v[i].y1-v[j].y1)*(v[i].y1-v[j].y1)) ^ stiva2.cpp:29:34: error: request for member 'x1' in 'v[j]', which is of non-class type 'int' d=sqrt((v[i].x1-v[j].x1)*(v[i].x1-v[j].x1)+(v[i].y1-v[j].y1)*(v[i].y1-v[j].y1)) ^ stiva2.cpp:29:44: error: request for member 'x1' in 'v[i]', which is of non-class type 'int' d=sqrt((v[i].x1-v[j].x1)*(v[i].x1-v[j].x1)+(v[i].y1-v[j].y1)*(v[i].y1-v[j].y1)) ^ stiva2.cpp:29:52: error: request for member 'x1' in 'v[j]', which is of non-class type 'int' d=sqrt((v[i].x1-v[j].x1)*(v[i].x1-v[j].x1)+(v[i].y1-v[j].y1)*(v[i].y1-v[j].y1)) ^ stiva2.cpp:29:62: error: request for member 'y1' in 'v[i]', which is of non-class type 'int' d=sqrt((v[i].x1-v[j].x1)*(v[i].x1-v[j].x1)+(v[i].y1-v[j].y1)*(v[i].y1-v[j].y1)) ^ stiva2.cpp:29:70: error: request for member 'y1' in 'v[j]', which is of non-class type 'int' d=sqrt((v[i].x1-v[j].x1)*(v[i].x1-v[j].x1)+(v[i].y1-v[j].y1)*(v[i].y1-v[j].y1)) ^ stiva2.cpp:29:80: error: request for member 'y1' in 'v[i]', which is of non-class type 'int' d=sqrt((v[i].x1-v[j].x1)*(v[i].x1-v[j].x1)+(v[i].y1-v[j].y1)*(v[i].y1-v[j].y1)) ^ stiva2.cpp:29:88: error: request for member 'y1' in 'v[j]', which is of non-class type 'int' d=sqrt((v[i].x1-v[j].x1)*(v[i].x1-v[j].x1)+(v[i].y1-v[j].y1)*(v[i].y1-v[j].y1)) ^ stiva2.cpp:30:13: error: expected ';' before 'if' if(v[i].x2>=d) ^ stiva2.cpp:32:13: error: expected '}' before 'else' else return 0; ^ stiva2.cpp: At global scope: stiva2.cpp:34:5: error: expected unqualified-id before 'if' if(v[j].tip==0&&v[i].tip==1) ^ stiva2.cpp:37:9: error: expected unqualified-id before 'else' else return 0; ^ stiva2.cpp:39:1: error: expected declaration before '}' token } ^ stiva2.cpp: In function 'int bine(int, int)': stiva2.cpp:33:9: warning: control reaches end of non-void function [-Wreturn-type] } ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema stiva2 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ă.