#718
Mihai a primit de ziua sa un joc de şah special. Tabla jocului are forma pătrată, de dimensiune N dar unele poziţii sunt marcate ca obstacole şi ele nu pot fi ocupate cu piese. În plus, jocul său are o singură piesă, numită “nebun”. Două poziţii pe tablă sunt desemnate ca poziţie iniţială şi poziţie finală. Mihai vrea să determine o modalitate de a deplasa nebunul, cu un număr minim de mutări, astfel încât acesta să ajungă din poziţia iniţială în poziţia finală. Mihai va respecta regulile de mutare a nebunului la jocul de şah, adică din poziţia curentă nebunul se poate muta doar pe diagonală, în oricare dintre cele 4 direcţii, oricâte poziţii deodată dar fără a sări peste obstacole. În plus, Mihai are voie la o excepţie de la această regulă: îi este permis să execute cel mult două mutări după regula de avansare a calului pe tabla de şah.
Dată fiind configuraţia tablei de şah precum şi poziţiile iniţială şi finală ale piesei, se cere determinarea numărului minim de mutări pentru a deplasa piesa între cele două poziţii.
| Problema | Sah2 | Operații I/O |
sah2.in/sah2.out
|
|---|---|---|---|
| Limita timp | 0.3 secunde | Limita memorie |
Total: 32 MB
/
Stivă 8 MB
|
| Id soluție | #59136193 | Utilizator | |
| Fișier | sah2.cpp | Dimensiune | 2.25 KB |
| Data încărcării | 18 Septembrie 2025, 16:04 | Scor/rezultat | Eroare de compilare |
sah2.cpp: In function 'int main()': sah2.cpp:26:21: error: converting to 'std::queue<std::tuple<int, int, int> >::value_type {aka std::tuple<int, int, int>}' from initializer list would use explicit constructor 'constexpr std::tuple< <template-parameter-1-1> >::tuple(_UElements&& ...) [with _UElements = {int&, int&, int}; <template-parameter-2-2> = void; _Elements = {int, int, int}]' q.push({i1,j3,0}); ^ sah2.cpp:31:14: error: expected unqualified-id before '[' token auto [x,y,z]=q.front(); ^ sah2.cpp:33:12: error: 'x' was not declared in this scope if(x==i2&&y==j2) continue; ^ sah2.cpp:33:19: error: 'y' was not declared in this scope if(x==i2&&y==j2) continue; ^ sah2.cpp:36:21: error: 'x' was not declared in this scope if(!bun(x+i,y+i)) break; ^ sah2.cpp:36:25: error: 'y' was not declared in this scope if(!bun(x+i,y+i)) break; ^ sah2.cpp:37:21: error: 'x' was not declared in this scope if(dist[x+i][y+i][z] <= dist[x][y][z]+1) continue; ^ sah2.cpp:37:26: error: 'y' was not declared in this scope if(dist[x+i][y+i][z] <= dist[x][y][z]+1) continue; ^ sah2.cpp:37:31: error: 'z' was not declared in this scope if(dist[x+i][y+i][z] <= dist[x][y][z]+1) continue; ^ sah2.cpp:39:18: error: 'x' was not declared in this scope dist[x+i][y+i][z]=min(dist[x+i][y+i][z],dist[x][y][z]+1); ^ sah2.cpp:39:23: error: 'y' was not declared in this scope dist[x+i][y+i][z]=min(dist[x+i][y+i][z],dist[x][y][z]+1); ^ sah2.cpp:39:28: error: 'z' was not declared in this scope dist[x+i][y+i][z]=min(dist[x+i][y+i][z],dist[x][y][z]+1); ^ sah2.cpp:40:31: error: no matching function for call to 'std::queue<std::tuple<int, int, int> >::push(<brace-enclosed initializer list>)' q.push({x+i,y+i,z}); ^ sah2.cpp:40:31: note: candidates are: In file included from /usr/include/c++/4.8/queue:64:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:85, from sah2.cpp:1: /usr/include/c++/4.8/bits/stl_queue.h:212:7: note: void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::deque<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::tuple<int, int, int>] push(const value_type& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:212:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::tuple<int, int, int>&}' /usr/include/c++/4.8/bits/stl_queue.h:217:7: note: void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::deque<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::tuple<int, int, int>] push(value_type&& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:217:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::tuple<int, int, int> >::value_type&& {aka std::tuple<int, int, int>&&}' sah2.cpp:43:21: error: 'x' was not declared in this scope if(!bun(x+i,y-i)) break; ^ sah2.cpp:43:25: error: 'y' was not declared in this scope if(!bun(x+i,y-i)) break; ^ sah2.cpp:44:21: error: 'x' was not declared in this scope if(dist[x+i][y-i][z] <= dist[x][y][z]+1) continue; ^ sah2.cpp:44:26: error: 'y' was not declared in this scope if(dist[x+i][y-i][z] <= dist[x][y][z]+1) continue; ^ sah2.cpp:44:31: error: 'z' was not declared in this scope if(dist[x+i][y-i][z] <= dist[x][y][z]+1) continue; ^ sah2.cpp:46:18: error: 'x' was not declared in this scope dist[x+i][y-i][z]=min(dist[x+i][y-i][z],dist[x][y][z]+1); ^ sah2.cpp:46:23: error: 'y' was not declared in this scope dist[x+i][y-i][z]=min(dist[x+i][y-i][z],dist[x][y][z]+1); ^ sah2.cpp:46:28: error: 'z' was not declared in this scope dist[x+i][y-i][z]=min(dist[x+i][y-i][z],dist[x][y][z]+1); ^ sah2.cpp:47:31: error: no matching function for call to 'std::queue<std::tuple<int, int, int> >::push(<brace-enclosed initializer list>)' q.push({x+i,y-i,z}); ^ sah2.cpp:47:31: note: candidates are: In file included from /usr/include/c++/4.8/queue:64:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:85, from sah2.cpp:1: /usr/include/c++/4.8/bits/stl_queue.h:212:7: note: void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::deque<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::tuple<int, int, int>] push(const value_type& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:212:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::tuple<int, int, int>&}' /usr/include/c++/4.8/bits/stl_queue.h:217:7: note: void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::deque<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::tuple<int, int, int>] push(value_type&& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:217:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::tuple<int, int, int> >::value_type&& {aka std::tuple<int, int, int>&&}' sah2.cpp:50:21: error: 'x' was not declared in this scope if(!bun(x-i,y+i)) break; ^ sah2.cpp:50:25: error: 'y' was not declared in this scope if(!bun(x-i,y+i)) break; ^ sah2.cpp:51:21: error: 'x' was not declared in this scope if(dist[x-i][y+i][z] <= dist[x][y][z]+1) continue; ^ sah2.cpp:51:26: error: 'y' was not declared in this scope if(dist[x-i][y+i][z] <= dist[x][y][z]+1) continue; ^ sah2.cpp:51:31: error: 'z' was not declared in this scope if(dist[x-i][y+i][z] <= dist[x][y][z]+1) continue; ^ sah2.cpp:53:18: error: 'x' was not declared in this scope dist[x-i][y+i][z]=min(dist[x-i][y+i][z],dist[x][y][z]+1); ^ sah2.cpp:53:23: error: 'y' was not declared in this scope dist[x-i][y+i][z]=min(dist[x-i][y+i][z],dist[x][y][z]+1); ^ sah2.cpp:53:28: error: 'z' was not declared in this scope dist[x-i][y+i][z]=min(dist[x-i][y+i][z],dist[x][y][z]+1); ^ sah2.cpp:54:31: error: no matching function for call to 'std::queue<std::tuple<int, int, int> >::push(<brace-enclosed initializer list>)' q.push({x-i,y+i,z}); ^ sah2.cpp:54:31: note: candidates are: In file included from /usr/include/c++/4.8/queue:64:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:85, from sah2.cpp:1: /usr/include/c++/4.8/bits/stl_queue.h:212:7: note: void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::deque<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::tuple<int, int, int>] push(const value_type& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:212:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::tuple<int, int, int>&}' /usr/include/c++/4.8/bits/stl_queue.h:217:7: note: void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::deque<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::tuple<int, int, int>] push(value_type&& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:217:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::tuple<int, int, int> >::value_type&& {aka std::tuple<int, int, int>&&}' sah2.cpp:57:21: error: 'x' was not declared in this scope if(!bun(x-i,y-i)) break; ^ sah2.cpp:57:25: error: 'y' was not declared in this scope if(!bun(x-i,y-i)) break; ^ sah2.cpp:58:21: error: 'x' was not declared in this scope if(dist[x-i][y-i][z] <= dist[x][y][z]+1) continue; ^ sah2.cpp:58:26: error: 'y' was not declared in this scope if(dist[x-i][y-i][z] <= dist[x][y][z]+1) continue; ^ sah2.cpp:58:31: error: 'z' was not declared in this scope if(dist[x-i][y-i][z] <= dist[x][y][z]+1) continue; ^ sah2.cpp:60:18: error: 'x' was not declared in this scope dist[x-i][y-i][z]=min(dist[x-i][y-i][z],dist[x][y][z]+1); ^ sah2.cpp:60:23: error: 'y' was not declared in this scope dist[x-i][y-i][z]=min(dist[x-i][y-i][z],dist[x][y][z]+1); ^ sah2.cpp:60:28: error: 'z' was not declared in this scope dist[x-i][y-i][z]=min(dist[x-i][y-i][z],dist[x][y][z]+1); ^ sah2.cpp:61:31: error: no matching function for call to 'std::queue<std::tuple<int, int, int> >::push(<brace-enclosed initializer list>)' q.push({x-i,y-i,z}); ^ sah2.cpp:61:31: note: candidates are: In file included from /usr/include/c++/4.8/queue:64:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:85, from sah2.cpp:1: /usr/include/c++/4.8/bits/stl_queue.h:212:7: note: void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::deque<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::tuple<int, int, int>] push(const value_type& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:212:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::tuple<int, int, int>&}' /usr/include/c++/4.8/bits/stl_queue.h:217:7: note: void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::deque<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::tuple<int, int, int>] push(value_type&& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:217:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::tuple<int, int, int> >::value_type&& {aka std::tuple<int, int, int>&&}' sah2.cpp:64:12: error: 'z' was not declared in this scope if(z==2) continue; ^ sah2.cpp:67:20: error: 'x' was not declared in this scope int nx=x+dl[d],ny=y+dc[d]; ^ sah2.cpp:68:24: error: 'ny' was not declared in this scope if(!bun(nx,ny)) continue; ^ sah2.cpp:69:25: error: 'ny' was not declared in this scope if(dist[nx][ny][z+1] <= dist[x][y][z]+1) continue; ^ sah2.cpp:69:29: error: 'z' was not declared in this scope if(dist[nx][ny][z+1] <= dist[x][y][z]+1) continue; ^ sah2.cpp:69:45: error: 'y' was not declared in this scope if(dist[nx][ny][z+1] <= dist[x][y][z]+1) continue; ^ sah2.cpp:71:22: error: 'ny' was not declared in this scope dist[nx][ny][z+1]=min(dist[nx][ny][z+1],dist[x][y][z]+1); ^ sah2.cpp:71:26: error: 'z' was not declared in this scope dist[nx][ny][z+1]=min(dist[nx][ny][z+1],dist[x][y][z]+1); ^ sah2.cpp:71:61: error: 'y' was not declared in this scope dist[nx][ny][z+1]=min(dist[nx][ny][z+1],dist[x][y][z]+1); ^ sah2.cpp:72:30: error: no matching function for call to 'std::queue<std::tuple<int, int, int> >::push(<brace-enclosed initializer list>)' q.push({nx,ny,z+1}); ^ sah2.cpp:72:30: note: candidates are: In file included from /usr/include/c++/4.8/queue:64:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:85, from sah2.cpp:1: /usr/include/c++/4.8/bits/stl_queue.h:212:7: note: void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::deque<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::tuple<int, int, int>] push(const value_type& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:212:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::tuple<int, int, int>&}' /usr/include/c++/4.8/bits/stl_queue.h:217:7: note: void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::tuple<int, int, int>; _Sequence = std::deque<std::tuple<int, int, int>, std::allocator<std::tuple<int, int, int> > >; std::queue<_Tp, _Sequence>::value_type = std::tuple<int, int, int>] push(value_type&& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:217:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::tuple<int, int, int> >::value_type&& {aka std::tuple<int, int, int>&&}'
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Sah2 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ă.