#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 | #64111229 | Utilizator | |
| Fișier | hamilton.cpp | Dimensiune | 941 B |
| 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 suc(int)’: hamilton.cpp:7:8: error: ‘n’ was not declared in this scope 7 | {if(k<=n+1&&x[k]<n) | ^ hamilton.cpp:7:13: error: ‘x’ was not declared in this scope 7 | {if(k<=n+1&&x[k]<n) | ^ hamilton.cpp: In function ‘int valid(int)’: hamilton.cpp:14:13: error: ‘n’ was not declared in this scope 14 | for(i=1;i<=n;i++) | ^ hamilton.cpp:15:9: error: ‘x’ was not declared in this scope 15 | if(x[i]==x[a]) | ^ hamilton.cpp:15:17: error: ‘a’ was not declared in this scope 15 | if(x[i]==x[a]) | ^ hamilton.cpp:14:2: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 14 | for(i=1;i<=n;i++) | ^~~ hamilton.cpp:17:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 17 | if(a[x[k-1]]x[i]==0) | ^~ hamilton.cpp:17:9: error: ‘a’ was not declared in this scope 17 | if(a[x[k-1]]x[i]==0) | ^ hamilton.cpp:17:11: error: ‘x’ was not declared in this scope 17 | if(a[x[k-1]]x[i]==0) | ^ hamilton.cpp:17:18: error: expected ‘)’ before ‘x’ 17 | if(a[x[k-1]]x[i]==0) | ~ ^ | ) hamilton.cpp: In function ‘int sol(int)’: hamilton.cpp:22:5: error: ‘k’ was not declared in this scope 22 | {if(k==n&&x[k]==x[1]) | ^ hamilton.cpp:22:8: error: ‘n’ was not declared in this scope 22 | {if(k==n&&x[k]==x[1]) | ^ hamilton.cpp:22:11: error: ‘x’ was not declared in this scope 22 | {if(k==n&&x[k]==x[1]) | ^ hamilton.cpp: In function ‘void afis(int)’: hamilton.cpp:28:2: error: ‘nrs’ was not declared in this scope 28 | nrs++; | ^~~ hamilton.cpp:29:2: error: ‘g’ was not declared in this scope 29 | g<<1<<endl; | ^ hamilton.cpp:30:13: error: ‘n’ was not declared in this scope 30 | for(i=1;i<=n;i++) | ^ hamilton.cpp:31:12: error: ‘x’ was not declared in this scope 31 | cout<<x[i]<<" "; | ^ hamilton.cpp: In function ‘void back()’: hamilton.cpp:35:2: error: ‘x’ was not declared in this scope 35 | x[1]=1; | ^ hamilton.cpp:38:13: error: ‘nrs’ was not declared in this scope 38 | while(k>1&&nrs==0) | ^~~ hamilton.cpp:39:3: warning: this ‘while’ clause does not guard... [-Wmisleading-indentation] 39 | {while (ok==0 && suc(k)) | ^~~~~ hamilton.cpp:42:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘while’ 42 | if(ok==0) | ^~ hamilton.cpp: In function ‘int main()’: hamilton.cpp:56:8: error: ‘n’ was not declared in this scope; did you mean ‘yn’? 56 | f>>n; | ^ | yn hamilton.cpp:57:14: error: ‘y’ was not declared in this scope; did you mean ‘yn’? 57 | while(f>>y>>x) | ^ | yn hamilton.cpp:57:17: error: ‘x’ was not declared in this scope 57 | while(f>>y>>x) | ^ hamilton.cpp:59:9: error: ‘a’ was not declared in this scope 59 | a[x][y]=a[y][x]=1; | ^ hamilton.cpp:60:9: error: ‘nrs’ was not declared in this scope 60 | nrs=0; | ^~~ hamilton.cpp:63:13: error: ‘g’ was not declared in this scope 63 | g<<0; | ^
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ă.