#628
Lui Andrei îi plac foarte mult jocurile de tip puzzle. De curând, el a descoperit un joc nou: un cub de dimensiune n
format din n•n•n
cuburi unitate sub forma unor cămăruţe. Cubul poate fi văzut ca o matrice tridimensionala ale cărei elemente sunt cămăruţele. Două cămăruţe se numesc adiacente dacă au o faţă comună. Astfel, o cămăruţă poate fi adiacentă cu maxim 6
cămăruţe. Scopul jocului este acela de a duce o bilă din cămăruţa de coordonate (1,1,1)
în cămăruţa de coordonate (n,n,n)
. Bila poate trece dintr-o cămăruţă în alta doar dacă acestea sunt adiacente, iar noua cămăruţă este accesibilă din cămăruţa curentă.
Cunoscând n
, dimensiunea cubului şi valorile asociate fiecărei cămăruţe, determinaţi:
a) cămăruța cu un număr maxim de cămăruțe ce pot fi accesate din ea;
b) un drum de lungime minimă de la cămăruţa (1,1,1)
la cămăruţa (n,n,n)
.
Grigore Moisil, 2014
Problema | Cub1 | Operații I/O |
![]() cub1.in /cub1.out
|
---|---|---|---|
Limita timp | 2 secunde | Limita memorie |
Total: 32 MB
/
Stivă 16 MB
|
Id soluție | #57010989 | Utilizator | |
Fișier | cub1.cpp | Dimensiune | 3.63 KB |
Data încărcării | 13 Martie 2025, 08:27 | Scor / rezultat | Eroare de compilare |
cub1.cpp: In function 'int bfs(int, int, int)': cub1.cpp:17:39: 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({i_start, j_start, k_start}); ^ cub1.cpp:22:14: error: expected unqualified-id before '[' token auto [i, j, k] = q.front(); ^ cub1.cpp:27:19: error: 'i' was not declared in this scope if (x[i][j][k] & (1 << d)) { ^ cub1.cpp:27:22: error: 'j' was not declared in this scope if (x[i][j][k] & (1 << d)) { ^ cub1.cpp:27:25: error: 'k' was not declared in this scope if (x[i][j][k] & (1 << d)) { ^ cub1.cpp:34:44: 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({ni, nj, nk}); ^ cub1.cpp: In function 'void solve_p2()': cub1.cpp:71: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({1, 1, 1}); ^ cub1.cpp:77:14: error: expected unqualified-id before '[' token auto [i, j, k] = q.front(); ^ cub1.cpp:80:13: error: 'i' was not declared in this scope if (i == n && j == n && k == n) { ^ cub1.cpp:80:23: error: 'j' was not declared in this scope if (i == n && j == n && k == n) { ^ cub1.cpp:80:33: error: 'k' was not declared in this scope if (i == n && j == n && k == n) { ^ cub1.cpp:86:19: error: 'i' was not declared in this scope if (x[i][j][k] & (1 << d)) { ^ cub1.cpp:86:22: error: 'j' was not declared in this scope if (x[i][j][k] & (1 << d)) { ^ cub1.cpp:86:25: error: 'k' was not declared in this scope if (x[i][j][k] & (1 << d)) { ^ cub1.cpp:95:44: error: no match for 'operator=' (operand types are 'std::tuple<int, int, int>' and '<brace-enclosed initializer list>') parent[ni][nj][nk] = {i, j, k}; ^ cub1.cpp:95:44: note: candidates are: In file included from /usr/include/c++/4.8/functional:55:0, from /usr/include/c++/4.8/bits/stl_algo.h:66, from /usr/include/c++/4.8/algorithm:62, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64, from cub1.cpp:1: /usr/include/c++/4.8/tuple:472:7: note: std::tuple< <template-parameter-1-1> >& std::tuple< <template-parameter-1-1> >::operator=(const std::tuple< <template-parameter-1-1> >&) [with _Elements = {int, int, int}] operator=(const tuple& __in) ^ /usr/include/c++/4.8/tuple:472:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::tuple<int, int, int>&' /usr/include/c++/4.8/tuple:479:7: note: std::tuple< <template-parameter-1-1> >& std::tuple< <template-parameter-1-1> >::operator=(std::tuple< <template-parameter-1-1> >&&) [with _Elements = {int, int, int}] operator=(tuple&& __in) ^ /usr/include/c++/4.8/tuple:479:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::tuple<int, int, int>&&' /usr/include/c++/4.8/tuple:490:9: note: template<class ... _UElements, class> std::tuple< <template-parameter-1-1> >& std::tuple< <template-parameter-1-1> >::operator=(const std::tuple<_Args1 ...>&) [with _UElements = {_UElements ...}; <template-parameter-2-2> = <template-parameter-1-2>; _Elements = {int, int, int}] operator=(const tuple<_UElements...>& __in) ^ /usr/include/c++/4.8/tuple:490:9: note: template argument deduction/substitution failed: /usr/include/c++/4.8/tuple:486:40: error: no type named 'type' in 'struct std::enable_if<false, void>' template<typename... _UElements, typename = typename ^ /usr/include/c++/4.8/tuple:500:9: note: template<class ... _UElements, class> std::tuple< <template-parameter-1-1> >& std::tuple< <template-parameter-1-1> >::operator=(std::tuple<_Args1 ...>&&) [with _UElements = {_UElements ...}; <template-parameter-2-2> = <template-parameter-1-2>; _Elements = {int, int, int}] operator=(tuple<_UElements...>&& __in) ^ /usr/include/c++/4.8/tuple:500:9: note: template argument deduction/substitution failed: /usr/include/c++/4.8/tuple:496:40: error: no type named 'type' in 'struct std::enable_if<false, void>' template<typename... _UElements, typename = typename ^ cub1.cpp:96:44: 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({ni, nj, nk}); ^ cub1.cpp:111:33: error: converting to 'std::vector<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}]' path.push_back({i, j, k}); ^ cub1.cpp:112:14: error: expected unqualified-id before '[' token auto [pi, pj, pk] = parent[i][j][k]; ^ cub1.cpp:113:13: error: 'pi' was not declared in this scope i = pi; ^ cub1.cpp:114:13: error: 'pj' was not declared in this scope j = pj; ^ cub1.cpp:115:13: error: 'pk' was not declared in this scope k = pk; ^ cub1.cpp:117:29: error: converting to 'std::vector<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}]' path.push_back({1, 1, 1}); ^ cub1.cpp:121:15: error: expected unqualified-id before '[' token for (auto [ci, cj, ck] : path) { ^ cub1.cpp:121:15: error: expected ';' before '[' token cub1.cpp:121:16: error: 'ci' was not declared in this scope for (auto [ci, cj, ck] : path) { ^ cub1.cpp:121:20: error: 'cj' was not declared in this scope for (auto [ci, cj, ck] : path) { ^ cub1.cpp:121:24: error: 'ck' was not declared in this scope for (auto [ci, cj, ck] : path) { ^ cub1.cpp: In lambda function: cub1.cpp:121:28: error: expected '{' before ':' token for (auto [ci, cj, ck] : path) { ^ cub1.cpp: In function 'void solve_p2()': cub1.cpp:121:28: error: expected ';' before ':' token cub1.cpp:121:28: error: expected primary-expression before ':' token cub1.cpp:121:28: error: expected ')' before ':' token cub1.cpp:121:28: error: expected primary-expression before ':' token cub1.cpp:121:28: error: expected ';' before ':' token
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Cub1 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ă.