#4995
În laboratoarele Marii Ghilde, ucenicul Jean Carapace are pe masa de lucru N eprubete asezate in linie. Eprubetele sunt numerotate de la stanga la dreapta cu indici de la 1 la N. Fiecare eprubetă i conține inițial o cantitate de Esență Primordială, V[i] , număr natural nenul. Definim o „Pereche Pură” ca fiind două eprubete vecine ale căror cantități sunt reprezentate prin numere prime între ele, adică cmmdc(V[i] , V[i+1]) = 1. O proprietate esențială a configurației inițiale este că se garantează existent, a a cel puțin unei astfel de perechi.
Scopul lui este să obțină „Scara Perfectă”, adică o configurație în care cantitatea de esență din fiecare eprubetă este
egală cu indicele ei:
Eprubeta 1 = 1, Eprubeta 2 = 2, …, Eprubeta N = N.

Pentru a modifica nivelul substanței, el poate folosi doar fenomenul de Rezonanță între două eprubete vecine. Mai exact, operațiile se aplică pe două eprubete situate la indicii A și B, cu condiția ca |A − B| = 1. Operațiile permise sunt:
adun A B ⇒ V[A] ← V[A] + V[B] (Eprubeta A câștigă o cantitate de esență egală cu valoarea din eprubeta B)scad A B ⇒ V[A] ← V[A] − V[B] (Eprubeta A pierde o cantitate de esență egală cu valoarea din eprubeta B)La aplicarea operațiilor, trebuie respectate următoarele reguli:
1. La fiecare operație, doar eprubeta cu indicele A își modifică valoarea. Eprubeta cu indicele B rămâne neschimbată.
2. Cantitatea de esență din orice eprubetă trebuie să se mențină în intervalul de siguranță [1, 10sup>5] în orice moment (inclusiv intermediar).
3. Numărul total de operații nu poate depăși 106.
Se cunosc C (numărul cerinței, 1 sau 2), N numărul de eprubete, precum și valorile V[i]. Determinați:
C = 1. Dacă există mai multe astfel de secvențe, se va afișa cea cu indicele de început minim.C = 2.ONI 2026, clasa a 7-a
| Problema | Alchimie | Operații I/O |
alchimie.in/alchimie.out
|
|---|---|---|---|
| Limita timp | 0.2 secunde | Limita memorie |
Total: 16 MB
/
Stivă 8 MB
|
| Id soluție | #64123058 | Utilizator | |
| Fișier | alchimie.cpp | Dimensiune | 4.71 KB |
| Data încărcării | 18 Aprilie 2026, 17:03 | Scor/rezultat | 50 puncte |
alchimie.cpp: In function ‘int main()’: alchimie.cpp:73:31: warning: narrowing conversion of ‘st’ from ‘int’ to ‘short int’ [-Wnarrowing] 73 | ans.push_back({0, st, dr}); | ^~ alchimie.cpp:73:35: warning: narrowing conversion of ‘dr’ from ‘int’ to ‘short int’ [-Wnarrowing] 73 | ans.push_back({0, st, dr}); | ^~ alchimie.cpp:78:31: warning: narrowing conversion of ‘dr’ from ‘int’ to ‘short int’ [-Wnarrowing] 78 | ans.push_back({0, dr, st}); | ^~ alchimie.cpp:78:35: warning: narrowing conversion of ‘st’ from ‘int’ to ‘short int’ [-Wnarrowing] 78 | ans.push_back({0, dr, st}); | ^~ alchimie.cpp:97:35: warning: narrowing conversion of ‘p1’ from ‘int’ to ‘short int’ [-Wnarrowing] 97 | ans.push_back({1, p1, p2}); | ^~ alchimie.cpp:97:39: warning: narrowing conversion of ‘p2’ from ‘int’ to ‘short int’ [-Wnarrowing] 97 | ans.push_back({1, p1, p2}); | ^~ alchimie.cpp:107:35: warning: narrowing conversion of ‘p2’ from ‘int’ to ‘short int’ [-Wnarrowing] 107 | ans.push_back({1, p2, p1}); | ^~ alchimie.cpp:107:39: warning: narrowing conversion of ‘p1’ from ‘int’ to ‘short int’ [-Wnarrowing] 107 | ans.push_back({1, p2, p1}); | ^~ alchimie.cpp:118:39: warning: narrowing conversion of ‘p1’ from ‘int’ to ‘short int’ [-Wnarrowing] 118 | ans.push_back({0, p1, p2}); | ^~ alchimie.cpp:118:43: warning: narrowing conversion of ‘p2’ from ‘int’ to ‘short int’ [-Wnarrowing] 118 | ans.push_back({0, p1, p2}); | ^~ alchimie.cpp:123:39: warning: narrowing conversion of ‘p2’ from ‘int’ to ‘short int’ [-Wnarrowing] 123 | ans.push_back({0, p2, p1}); | ^~ alchimie.cpp:123:43: warning: narrowing conversion of ‘p1’ from ‘int’ to ‘short int’ [-Wnarrowing] 123 | ans.push_back({0, p2, p1}); | ^~ alchimie.cpp:130:35: warning: narrowing conversion of ‘i’ from ‘int’ to ‘short int’ [-Wnarrowing] 130 | ans.push_back({0, i, p2}); | ^ alchimie.cpp:130:38: warning: narrowing conversion of ‘p2’ from ‘int’ to ‘short int’ [-Wnarrowing] 130 | ans.push_back({0, i, p2}); | ^~ alchimie.cpp:139:35: warning: narrowing conversion of ‘p1’ from ‘int’ to ‘short int’ [-Wnarrowing] 139 | ans.push_back({0, p1, p2}); | ^~ alchimie.cpp:139:39: warning: narrowing conversion of ‘p2’ from ‘int’ to ‘short int’ [-Wnarrowing] 139 | ans.push_back({0, p1, p2}); | ^~ alchimie.cpp:144:35: warning: narrowing conversion of ‘p2’ from ‘int’ to ‘short int’ [-Wnarrowing] 144 | ans.push_back({0, p2, p1}); | ^~ alchimie.cpp:144:39: warning: narrowing conversion of ‘p1’ from ‘int’ to ‘short int’ [-Wnarrowing] 144 | ans.push_back({0, p2, p1}); | ^~ alchimie.cpp:164:35: warning: narrowing conversion of ‘p1’ from ‘int’ to ‘short int’ [-Wnarrowing] 164 | ans.push_back({1, p1, p2}); | ^~ alchimie.cpp:164:39: warning: narrowing conversion of ‘p2’ from ‘int’ to ‘short int’ [-Wnarrowing] 164 | ans.push_back({1, p1, p2}); | ^~ alchimie.cpp:174:35: warning: narrowing conversion of ‘p2’ from ‘int’ to ‘short int’ [-Wnarrowing] 174 | ans.push_back({1, p2, p1}); | ^~ alchimie.cpp:174:39: warning: narrowing conversion of ‘p1’ from ‘int’ to ‘short int’ [-Wnarrowing] 174 | ans.push_back({1, p2, p1}); | ^~ alchimie.cpp:185:39: warning: narrowing conversion of ‘p1’ from ‘int’ to ‘short int’ [-Wnarrowing] 185 | ans.push_back({0, p1, p2}); | ^~ alchimie.cpp:185:43: warning: narrowing conversion of ‘p2’ from ‘int’ to ‘short int’ [-Wnarrowing] 185 | ans.push_back({0, p1, p2}); | ^~ alchimie.cpp:190:39: warning: narrowing conversion of ‘p2’ from ‘int’ to ‘short int’ [-Wnarrowing] 190 | ans.push_back({0, p2, p1}); | ^~ alchimie.cpp:190:43: warning: narrowing conversion of ‘p1’ from ‘int’ to ‘short int’ [-Wnarrowing] 190 | ans.push_back({0, p2, p1}); | ^~ alchimie.cpp:197:35: warning: narrowing conversion of ‘i’ from ‘int’ to ‘short int’ [-Wnarrowing] 197 | ans.push_back({0, i, p2}); | ^ alchimie.cpp:197:38: warning: narrowing conversion of ‘p2’ from ‘int’ to ‘short int’ [-Wnarrowing] 197 | ans.push_back({0, i, p2}); | ^~ alchimie.cpp:206:35: warning: narrowing conversion of ‘p1’ from ‘int’ to ‘short int’ [-Wnarrowing] 206 | ans.push_back({0, p1, p2}); | ^~ alchimie.cpp:206:39: warning: narrowing conversion of ‘p2’ from ‘int’ to ‘short int’ [-Wnarrowing] 206 | ans.push_back({0, p1, p2}); | ^~ alchimie.cpp:211:35: warning: narrowing conversion of ‘p2’ from ‘int’ to ‘short int’ [-Wnarrowing] 211 | ans.push_back({0, p2, p1}); | ^~ alchimie.cpp:211:39: warning: narrowing conversion of ‘p1’ from ‘int’ to ‘short int’ [-Wnarrowing] 211 | ans.push_back({0, p2, p1}); | ^~ alchimie.cpp:219:27: warning: narrowing conversion of ‘i’ from ‘int’ to ‘short int’ [-Wnarrowing] 219 | ans.push_back({1, i, i - 1}); | ^ alchimie.cpp:219:32: warning: narrowing conversion of ‘(i - 1)’ from ‘int’ to ‘short int’ [-Wnarrowing] 219 | ans.push_back({1, i, i - 1}); | ~~^~~ alchimie.cpp:69:15: warning: ‘st’ may be used uninitialized [-Wmaybe-uninitialized] 69 | while(v[st] > 1 || v[dr] > 1) | ~~~~^ alchimie.cpp:58:9: note: ‘st’ was declared here 58 | int st, dr; | ^~ alchimie.cpp:71:24: warning: ‘dr’ may be used uninitialized [-Wmaybe-uninitialized] 71 | if(v[st] > v[dr]) | ~~~~^ alchimie.cpp:58:13: note: ‘dr’ was declared here 58 | int st, dr; | ^~
| Test | Timp | Mesaj evaluare | Scor posibil | Scor obținut | ||
|---|---|---|---|---|---|---|
| 1 | 0.002 secunde | OK. | 2 | 2 | ||
| 2 | 0.002 secunde | OK. | 2 | 2 | ||
| 3 | 0.003 secunde | OK. | 2 | 2 | ||
| 4 | 0.002 secunde | OK. | 2 | 2 | ||
| 5 | 0.002 secunde | OK. | 2 | 2 | ||
| 6 | 0.002 secunde | OK. | 2 | 2 | ||
| 7 | 0.001 secunde | OK. | 2 | 2 | ||
| 8 | 0.001 secunde | OK. | 2 | 2 | ||
| 9 | 0.003 secunde | OK. | 2 | 2 | ||
| 10 | 0.004 secunde | OK. | 2 | 2 | ||
| 11 | 0.006 secunde | OK. | 2 | 2 | ||
| 12 | 0.002 secunde | OK. | 2 | 2 | ||
| 13 | 0.003 secunde | OK. | 2 | 2 | ||
| 14 | 0.003 secunde | OK. | 2 | 2 | ||
| 15 | 0.005 secunde | OK. | 2 | 2 | ||
| 16 | 0.002 secunde | OK. | 2 | 2 | ||
| 17 | 0.001 secunde | OK. | 2 | 2 | ||
| 18 | 0.002 secunde | OK. | 2 | 2 | ||
| 19 | 0.002 secunde | OK. | 2 | 2 | ||
| 20 | 0.004 secunde | OK. | 2 | 2 | ||
| 21 | 0.003 secunde | OK. | 2 | 2 | ||
| 22 | 0.001 secunde | Raspuns gresit. | 2 | 0 | ||
| 23 | 0.001 secunde | Raspuns gresit. | 2 | 0 | ||
| 24 | 0.002 secunde | Raspuns gresit. | 2 | 0 | ||
| 25 | 0.002 secunde | Raspuns gresit. | 2 | 0 | ||
| 26 | 0.002 secunde | Raspuns gresit. | 2 | 0 | ||
| 27 | 0.001 secunde | Raspuns gresit. | 2 | 0 | ||
| 28 | 0.001 secunde | Raspuns gresit. | 2 | 0 | ||
| 29 | 0.004 secunde | Raspuns gresit. | 2 | 0 | ||
| 30 | 0.001 secunde | Raspuns gresit. | 2 | 0 | ||
| 31 | 0.002 secunde | Raspuns gresit. | 2 | 0 | ||
| 32 | 0.003 secunde | Raspuns gresit. | 2 | 0 | ||
| 33 | 0.045 secunde | Raspuns gresit. | 2 | 0 | ||
| 34 | 0.042 secunde | Raspuns gresit. | 2 | 0 | ||
| 35 | 0.045 secunde | Raspuns gresit. | 2 | 0 | ||
| 36 | 0.028 secunde | Raspuns gresit. | 2 | 0 | ||
| 37 | 0.03 secunde | Raspuns gresit. | 2 | 0 | ||
| 38 | 0.064 secunde | Raspuns gresit. | 2 | 0 | ||
| 39 | 0.074 secunde | Raspuns gresit. | 2 | 0 | ||
| 40 | 0.056 secunde | Raspuns gresit. | 2 | 0 | ||
| 41 | 0.09 secunde | OK. | 4 | 4 | ||
| 42 | 0.072 secunde | Raspuns gresit. | 4 | 0 | ||
| 43 | 0.082 secunde | OK. | 4 | 4 | ||
| 44 | 0.059 secunde | Raspuns gresit. | 4 | 0 | ||
| 45 | 0.085 secunde | Raspuns gresit. | 4 | 0 | ||
| Punctaj total | 50 | |||||
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Alchimie 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ă.