#548
Se dă un graf neorientat cu n vârfuri. Determinați, dacă există, un ciclu hamiltonian.
| Problema | Hamilton | Operații I/O |
hamilton.in/hamilton.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64111223 | Utilizator | |
| Fișier | hamilton.cpp | Dimensiune | 1.25 KB |
| Data încărcării | 17 Aprilie 2026, 14:18 | Scor/rezultat | Eroare de compilare |
hamilton.cpp:4:1: error: expected ‘,’ or ‘;’ before ‘ofstream’ 4 | ofstream g("hamilton.out") | ^~~~~~~~ hamilton.cpp: In function ‘int succ(int)’: hamilton.cpp:7:14: error: ‘n’ was not declared in this scope 7 | {if(k<=n++&&x[k]<n) | ^ hamilton.cpp:7:19: error: ‘x’ was not declared in this scope 7 | {if(k<=n++&&x[k]<n) | ^ hamilton.cpp: In function ‘int valid(int)’: hamilton.cpp:15:20: error: ‘n’ was not declared in this scope 15 | for(i=1;i<=n;i++) | ^ hamilton.cpp:16:16: error: ‘x’ was not declared in this scope 16 | if(x[i]==x[k]) | ^ hamilton.cpp:18:18: error: ‘a’ was not declared in this scope 18 | if(a[x[k-1]][x[i]]==0) | ^ hamilton.cpp:18:20: error: ‘x’ was not declared in this scope 18 | if(a[x[k-1]][x[i]]==0) | ^ hamilton.cpp: In function ‘int sol(int)’: hamilton.cpp:23:14: error: ‘n’ was not declared in this scope 23 | {if(k==n && x[k]==x[1]) | ^ hamilton.cpp:23:19: error: ‘x’ was not declared in this scope 23 | {if(k==n && x[k]==x[1]) | ^ hamilton.cpp: In function ‘void afis(int)’: hamilton.cpp:29:9: error: ‘nrs’ was not declared in this scope 29 | nrs++; | ^~~ hamilton.cpp:31:13: error: ‘g’ was not declared in this scope 31 | g<<1<<endl; | ^ hamilton.cpp: In function ‘void back()’: hamilton.cpp:35:6: error: ‘x’ was not declared in this scope 35 | x[i]=1; | ^ hamilton.cpp:35:8: error: ‘i’ was not declared in this scope 35 | x[i]=1; | ^ hamilton.cpp:38:20: error: ‘nrs’ was not declared in this scope 38 | while(ok==0&& nrs==0) | ^~~ hamilton.cpp:39:10: warning: this ‘while’ clause does not guard... [-Wmisleading-indentation] 39 | {while(ok==0 && succ(k)) | ^~~~~ hamilton.cpp:41:16: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘while’ 41 | ok=1; | ^~ hamilton.cpp: At global scope: hamilton.cpp:54:9: error: expected initializer before ‘f’ 54 | f>>n; | ^ hamilton.cpp:55:5: error: expected unqualified-id before ‘while’ 55 | while(f>>y>>x) | ^~~~~ hamilton.cpp:58:5: error: ‘nrs’ does not name a type 58 | nrs=0; | ^~~ hamilton.cpp:59:11: error: expected constructor, destructor, or type conversion before ‘;’ token 59 | back(); | ^ hamilton.cpp:60:5: error: expected unqualified-id before ‘if’ 60 | if(nrs==0) | ^~ hamilton.cpp:62:1: error: expected unqualified-id before ‘return’ 62 | return 0; | ^~~~~~ hamilton.cpp:63:1: error: expected declaration before ‘}’ token 63 | } | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Hamilton 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ă.