#343
Se dă o tablă dreptunghiulară formată din n linii și m coloane, definind n*m zone, unele dintre ele fiind libere, altele conținând obstacole. Într-o zonă precizată se află un șoarece care se poate deplasa pe tablă trecând din zona curentă în zona învecinată cu aceasta pe linie sau pe coloană. Scopul sau este să ajungă la o bucată de brânză aflată într-o zonă de asemenea precizată, fără a părăsi tabla, fără a trece prin zone care conțin obstacole și fără a trece de două ori prin aceeași zonă.
Determinați o modalitate prin care șoarecele poate să ajungă la bucata de brânză.
| Problema | Soarece1 | Operații I/O |
soarece1.in/soarece1.out
|
|---|---|---|---|
| Limita timp | 1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #62865702 | Utilizator | |
| Fișier | soarece1.cpp | Dimensiune | 1.07 KB |
| Data încărcării | 04 Februarie 2026, 16:24 | Scor/rezultat | Eroare de compilare |
soarece1.cpp:4:15: warning: missing terminating " character [enabled by default] ofstream cout("soarece1.out); ^ soarece1.cpp:4:1: error: missing terminating " character ofstream cout("soarece1.out); ^ soarece1.cpp:5:8: error: 'm' has not been declared int n, m, a[12][12],t[12][12], si, sj, bi, bj, nr=0, di[]={0, 1, 0, -1}, dj[]={1, 0, -1, 0}; ^ soarece1.cpp:5:11: error: 'a' has not been declared int n, m, a[12][12],t[12][12], si, sj, bi, bj, nr=0, di[]={0, 1, 0, -1}, dj[]={1, 0, -1, 0}; ^ soarece1.cpp:5:21: error: 't' has not been declared int n, m, a[12][12],t[12][12], si, sj, bi, bj, nr=0, di[]={0, 1, 0, -1}, dj[]={1, 0, -1, 0}; ^ soarece1.cpp:5:32: error: 'si' has not been declared int n, m, a[12][12],t[12][12], si, sj, bi, bj, nr=0, di[]={0, 1, 0, -1}, dj[]={1, 0, -1, 0}; ^ soarece1.cpp:5:36: error: 'sj' has not been declared int n, m, a[12][12],t[12][12], si, sj, bi, bj, nr=0, di[]={0, 1, 0, -1}, dj[]={1, 0, -1, 0}; ^ soarece1.cpp:5:40: error: 'bi' has not been declared int n, m, a[12][12],t[12][12], si, sj, bi, bj, nr=0, di[]={0, 1, 0, -1}, dj[]={1, 0, -1, 0}; ^ soarece1.cpp:5:44: error: 'bj' has not been declared int n, m, a[12][12],t[12][12], si, sj, bi, bj, nr=0, di[]={0, 1, 0, -1}, dj[]={1, 0, -1, 0}; ^ soarece1.cpp:5:48: error: 'nr' has not been declared int n, m, a[12][12],t[12][12], si, sj, bi, bj, nr=0, di[]={0, 1, 0, -1}, dj[]={1, 0, -1, 0}; ^ soarece1.cpp:5:54: error: 'di' has not been declared int n, m, a[12][12],t[12][12], si, sj, bi, bj, nr=0, di[]={0, 1, 0, -1}, dj[]={1, 0, -1, 0}; ^ soarece1.cpp:5:74: error: 'dj' has not been declared int n, m, a[12][12],t[12][12], si, sj, bi, bj, nr=0, di[]={0, 1, 0, -1}, dj[]={1, 0, -1, 0}; ^ soarece1.cpp:5:92: error: expected ')' before ';' token int n, m, a[12][12],t[12][12], si, sj, bi, bj, nr=0, di[]={0, 1, 0, -1}, dj[]={1, 0, -1, 0}; ^ soarece1.cpp:5:92: error: could not convert '{0, 1, 0, -1}' from '<brace-enclosed initializer list>' to 'int*' soarece1.cpp:5:92: error: could not convert '{1, 0, -1, 0}' from '<brace-enclosed initializer list>' to 'int*' soarece1.cpp: In function 'void afisare()': soarece1.cpp:9:21: error: 'n' was not declared in this scope for(int i=1; i<=n; i++) ^ soarece1.cpp:11:25: error: 'm' was not declared in this scope for(int j=1; j<=m; j++) ^ soarece1.cpp:12:19: error: 't' was not declared in this scope cout<<t[i][j]<<' '; ^ soarece1.cpp:13:15: error: invalid operands of types 'std::ofstream(int, int, int (*)[12], int (*)[12], int, int, int, int, int, int*, int*) {aka std::basic_ofstream<char>(int, int, int (*)[12], int (*)[12], int, int, int, int, int, int*, int*)}' and '<unresolved overloaded function type>' to binary 'operator<<' cout<<endl; ^ soarece1.cpp: In function 'void bkt(int, int)': soarece1.cpp:20:5: error: 't' was not declared in this scope t[x][y]=++nr; ^ soarece1.cpp:20:15: error: 'nr' was not declared in this scope t[x][y]=++nr; ^ soarece1.cpp:21:11: error: 'bi' was not declared in this scope if(x==bi && y==bj) ^ soarece1.cpp:21:20: error: 'bj' was not declared in this scope if(x==bi && y==bj) ^ soarece1.cpp:26:22: error: 'di' was not declared in this scope int x1=x+di[k], y1=y+dj[k]; ^ soarece1.cpp:27:20: error: 'n' was not declared in this scope if(x1<=n && x1>=1 && y1<=n && y1>=1) ^ soarece1.cpp:27:34: error: 'y1' was not declared in this scope if(x1<=n && x1>=1 && y1<=n && y1>=1) ^ soarece1.cpp:28:20: error: 'a' was not declared in this scope if(a[x1][y1]==0 && t[x1][y1]==0) ^ soarece1.cpp: In function 'int main()': soarece1.cpp:38:10: error: 'n' was not declared in this scope cin>>n>>m; ^ soarece1.cpp:38:13: error: 'm' was not declared in this scope cin>>n>>m; ^ soarece1.cpp:44:17: error: 'a' was not declared in this scope a[i][j]=1; ^ soarece1.cpp:46:17: error: 'si' was not declared in this scope si=i, sj=j; ^ soarece1.cpp:46:23: error: 'sj' was not declared in this scope si=i, sj=j; ^ soarece1.cpp:48:17: error: 'bi' was not declared in this scope bi=i, bj=j; ^ soarece1.cpp:48:23: error: 'bj' was not declared in this scope bi=i, bj=j; ^ soarece1.cpp:50:9: error: 'si' was not declared in this scope bkt(si,sj); ^ soarece1.cpp:50:12: error: 'sj' was not declared in this scope bkt(si,sj); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Soarece1 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ă.