#4806
EscapeLight
Andrei se află într-un labirint format dintr-o matrice de camere, fiecare având unul dintre următoarele tipuri: 0
: cameră cu bec stins, 1
: cameră cu bec aprins, 2
: cameră fără bec (inaccesibilă), 3
: cameră cu întrerupător.
Camerele de tip 3
pot aprinde/stinge becurile altor camere. Andrei poate alege să apese sau nu întrerupătoarele întâlnite. El pornește dintr-o cameră dată și trebuie să ajungă într-o cameră destinație, deplasându-se doar prin camere aprinse.
Se cere determinarea distanței minime pentru a ajunge la destinație.
Concursul Național de Matematică și Informatică Grigore Moisil
Problema | EscapeLight | Operații I/O |
![]() escapelight.in /escapelight.out
|
---|---|---|---|
Limita timp | 0.7 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #58513910 | Utilizator | |
Fișier | escapelight.cpp | Dimensiune | 2.31 KB |
Data încărcării | 12 Iunie 2025, 21:41 | Scor / rezultat | Eroare de compilare |
escapelight.cpp: In lambda function: escapelight.cpp:58:9: error: expected unqualified-id before '[' token auto [x, y, mask, dist] = q.front(); ^ escapelight.cpp:60:25: error: 'x' was not declared in this scope if (end == make_pair(x, y)) { ^ escapelight.cpp:60:28: error: 'y' was not declared in this scope if (end == make_pair(x, y)) { ^ escapelight.cpp:61:12: error: 'dist' was not declared in this scope out << dist; ^ escapelight.cpp:64:12: error: 'x' was not declared in this scope if (mat[x][y] == 3 && !seen[x][y][mask ^ (1 << switches[{x, y}])]) { ^ escapelight.cpp:64:15: error: 'y' was not declared in this scope if (mat[x][y] == 3 && !seen[x][y][mask ^ (1 << switches[{x, y}])]) { ^ escapelight.cpp:64:38: error: 'mask' was not declared in this scope if (mat[x][y] == 3 && !seen[x][y][mask ^ (1 << switches[{x, y}])]) { ^ escapelight.cpp:64:59: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and '<brace-enclosed initializer list>') if (mat[x][y] == 3 && !seen[x][y][mask ^ (1 << switches[{x, y}])]) { ^ escapelight.cpp:64:59: note: candidates are: In file included from /usr/include/c++/4.8/map:61:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:80, from escapelight.cpp:1: /usr/include/c++/4.8/bits/stl_map.h:456:7: note: std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>] operator[](const key_type& __k) ^ /usr/include/c++/4.8/bits/stl_map.h:456:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type& {aka const std::pair<int, int>&}' /usr/include/c++/4.8/bits/stl_map.h:476:7: note: std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>] operator[](key_type&& __k) ^ /usr/include/c++/4.8/bits/stl_map.h:476:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::map<std::pair<int, int>, int>::key_type&& {aka std::pair<int, int>&&}' escapelight.cpp:65:37: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and '<brace-enclosed initializer list>') seen[x][y][mask ^ (1 << switches[{x, y}])] = true; ^ escapelight.cpp:65:37: note: candidates are: In file included from /usr/include/c++/4.8/map:61:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:80, from escapelight.cpp:1: /usr/include/c++/4.8/bits/stl_map.h:456:7: note: std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>] operator[](const key_type& __k) ^ /usr/include/c++/4.8/bits/stl_map.h:456:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type& {aka const std::pair<int, int>&}' /usr/include/c++/4.8/bits/stl_map.h:476:7: note: std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>] operator[](key_type&& __k) ^ /usr/include/c++/4.8/bits/stl_map.h:476:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::map<std::pair<int, int>, int>::key_type&& {aka std::pair<int, int>&&}' escapelight.cpp:66:46: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and '<brace-enclosed initializer list>') q.push_front({x, y, mask ^ (1 << switches[{x, y}]), dist}); ^ escapelight.cpp:66:46: note: candidates are: In file included from /usr/include/c++/4.8/map:61:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:80, from escapelight.cpp:1: /usr/include/c++/4.8/bits/stl_map.h:456:7: note: std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>] operator[](const key_type& __k) ^ /usr/include/c++/4.8/bits/stl_map.h:456:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const key_type& {aka const std::pair<int, int>&}' /usr/include/c++/4.8/bits/stl_map.h:476:7: note: std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::pair<int, int>] operator[](key_type&& __k) ^ /usr/include/c++/4.8/bits/stl_map.h:476:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::map<std::pair<int, int>, int>::key_type&& {aka std::pair<int, int>&&}' escapelight.cpp:66:57: error: 'dist' was not declared in this scope q.push_front({x, y, mask ^ (1 << switches[{x, y}]), dist}); ^ escapelight.cpp:66:62: error: no matching function for call to 'std::deque<std::array<int, 4u> >::push_front(<brace-enclosed initializer list>)' q.push_front({x, y, mask ^ (1 << switches[{x, y}]), dist}); ^ escapelight.cpp:66:62: note: candidates are: In file included from /usr/include/c++/4.8/deque:64:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:67, from escapelight.cpp:1: /usr/include/c++/4.8/bits/stl_deque.h:1359:7: note: void std::deque<_Tp, _Alloc>::push_front(const value_type&) [with _Tp = std::array<int, 4u>; _Alloc = std::allocator<std::array<int, 4u> >; std::deque<_Tp, _Alloc>::value_type = std::array<int, 4u>] push_front(const value_type& __x) ^ /usr/include/c++/4.8/bits/stl_deque.h:1359:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::array<int, 4u>&}' /usr/include/c++/4.8/bits/stl_deque.h:1372:7: note: void std::deque<_Tp, _Alloc>::push_front(std::deque<_Tp, _Alloc>::value_type&&) [with _Tp = std::array<int, 4u>; _Alloc = std::allocator<std::array<int, 4u> >; std::deque<_Tp, _Alloc>::value_type = std::array<int, 4u>] push_front(value_type&& __x) ^ /usr/include/c++/4.8/bits/stl_deque.h:1372:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::deque<std::array<int, 4u> >::value_type&& {aka std::array<int, 4u>&&}' escapelight.cpp:69:16: error: 'x' was not declared in this scope int newx = x + dx[dir], newy = y + dy[dir]; ^ escapelight.cpp:70:23: error: 'newy' was not declared in this scope if (inside({newx, newy}) && is_lit({newx, newy}, mask) && !seen[newx][newy][mask]) { ^ escapelight.cpp:70:28: error: no match for call to '(main()::__lambda5) (<brace-enclosed initializer list>)' if (inside({newx, newy}) && is_lit({newx, newy}, mask) && !seen[newx][newy][mask]) { ^ escapelight.cpp:46:18: note: candidate is: auto inside = [&](const pair<int, int>& cell) -> bool { ^ In file included from /usr/include/c++/4.8/cstdbool:39:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:56, from escapelight.cpp:1: escapelight.cpp:46:51: note: main()::__lambda5 auto inside = [&](const pair<int, int>& cell) -> bool { ^ escapelight.cpp:46:51: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::pair<int, int>&' escapelight.cpp:70:54: error: 'mask' was not declared in this scope if (inside({newx, newy}) && is_lit({newx, newy}, mask) && !seen[newx][newy][mask]) { ^ escapelight.cpp:71:37: error: 'dist' was not declared in this scope q.push_back({newx, newy, mask, dist + 1}); ^ escapelight.cpp:71:46: error: no matching function for call to 'std::deque<std::array<int, 4u> >::push_back(<brace-enclosed initializer list>)' q.push_back({newx, newy, mask, dist + 1}); ^ escapelight.cpp:71:46: note: candidates are: In file included from /usr/include/c++/4.8/deque:64:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:67, from escapelight.cpp:1: /usr/include/c++/4.8/bits/stl_deque.h:1390:7: note: void std::deque<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::array<int, 4u>; _Alloc = std::allocator<std::array<int, 4u> >; std::deque<_Tp, _Alloc>::value_type = std::array<int, 4u>] push_back(const value_type& __x) ^ /usr/include/c++/4.8/bits/stl_deque.h:1390:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::array<int, 4u>&}' /usr/include/c++/4.8/bits/stl_deque.h:1404:7: note: void std::deque<_Tp, _Alloc>::push_back(std::deque<_Tp, _Alloc>::value_type&&) [with _Tp = std::array<int, 4u>; _Alloc = std::allocator<std::array<int, 4u> >; std::deque<_Tp, _Alloc>::value_type = std::array<int, 4u>] push_back(value_type&& __x) ^ /usr/include/c++/4.8/bits/stl_deque.h:1404:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::deque<std::array<int, 4u> >::value_type&& {aka std::array<int, 4u>&&}' escapelight.cpp:52:13: warning: unused variable 'dy' [-Wunused-variable] const int dy[4] = {0, 1, 0, -1}; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema EscapeLight 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ă.