#4806
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 | #58333353 | Utilizator | |
Fișier | escapelight.cpp | Dimensiune | 3.03 KB |
Data încărcării | 27 Mai 2025, 19:15 | Scor / rezultat | Eroare de compilare |
escapelight.cpp: In function 'bool is_light(int, int, int)': escapelight.cpp:30:24: error: expected unqualified-id before '[' token for (auto& [lx, ly] : switch_map[switches_pos[i]]) { ^ escapelight.cpp:30:24: error: expected ';' before '[' token escapelight.cpp:30:25: error: 'lx' was not declared in this scope for (auto& [lx, ly] : switch_map[switches_pos[i]]) { ^ escapelight.cpp:30:29: error: 'ly' was not declared in this scope for (auto& [lx, ly] : switch_map[switches_pos[i]]) { ^ escapelight.cpp: In lambda function: escapelight.cpp:30:33: error: expected '{' before ':' token for (auto& [lx, ly] : switch_map[switches_pos[i]]) { ^ escapelight.cpp: In function 'bool is_light(int, int, int)': escapelight.cpp:30:33: error: expected ';' before ':' token escapelight.cpp:30:33: error: expected primary-expression before ':' token escapelight.cpp:30:33: error: expected ')' before ':' token escapelight.cpp:30:33: error: expected primary-expression before ':' token escapelight.cpp:30:33: error: expected ';' before ':' token escapelight.cpp: In function 'int bfs()': escapelight.cpp:47:14: error: expected unqualified-id before '[' token auto [x, y, d, mask] = pq.top(); pq.pop(); ^ escapelight.cpp:48:13: error: 'x' was not declared in this scope if (x == x_stop && y == y_stop) return d; ^ escapelight.cpp:48:28: error: 'y' was not declared in this scope if (x == x_stop && y == y_stop) return d; ^ escapelight.cpp:48:48: error: 'd' was not declared in this scope if (x == x_stop && y == y_stop) return d; ^ escapelight.cpp:51:18: error: 'x' was not declared in this scope if (grid[x][y] == 3) { ^ escapelight.cpp:51:21: error: 'y' was not declared in this scope if (grid[x][y] == 3) { ^ escapelight.cpp:52:32: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and '<brace-enclosed initializer list>') int sid = switch_id[{x, y}]; ^ escapelight.cpp:52:32: 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:53:28: error: 'mask' was not declared in this scope int new_mask = mask ^ (1 << sid); ^ escapelight.cpp:56:32: error: 'd' was not declared in this scope pq.push({x, y, d + 1, new_mask}); ^ escapelight.cpp:56:48: error: no matching function for call to 'std::priority_queue<State>::push(<brace-enclosed initializer list>)' pq.push({x, y, d + 1, new_mask}); ^ escapelight.cpp:56:48: 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 escapelight.cpp:1: /usr/include/c++/4.8/bits/stl_queue.h:496:7: note: void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = State; _Sequence = std::vector<State, std::allocator<State> >; _Compare = std::less<State>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = State] push(const value_type& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:496:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const State&}' /usr/include/c++/4.8/bits/stl_queue.h:504:7: note: void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = State; _Sequence = std::vector<State, std::allocator<State> >; _Compare = std::less<State>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = State] push(value_type&& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:504:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<State>::value_type&& {aka State&&}' escapelight.cpp:62:22: error: 'x' was not declared in this scope int nx = x + dx[dir], ny = y + dy[dir]; ^ escapelight.cpp:63:30: error: 'ny' was not declared in this scope if (is_light(nx, ny, mask) && !vis[nx][ny][mask]) { ^ escapelight.cpp:63:34: error: 'mask' was not declared in this scope if (is_light(nx, ny, mask) && !vis[nx][ny][mask]) { ^ escapelight.cpp:65:34: error: 'd' was not declared in this scope pq.push({nx, ny, d + 1, mask}); ^ escapelight.cpp:65:46: error: no matching function for call to 'std::priority_queue<State>::push(<brace-enclosed initializer list>)' pq.push({nx, ny, d + 1, mask}); ^ escapelight.cpp:65:46: 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 escapelight.cpp:1: /usr/include/c++/4.8/bits/stl_queue.h:496:7: note: void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = State; _Sequence = std::vector<State, std::allocator<State> >; _Compare = std::less<State>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = State] push(const value_type& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:496:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const State&}' /usr/include/c++/4.8/bits/stl_queue.h:504:7: note: void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = State; _Sequence = std::vector<State, std::allocator<State> >; _Compare = std::less<State>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = State] push(value_type&& __x) ^ /usr/include/c++/4.8/bits/stl_queue.h:504:7: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<State>::value_type&& {aka State&&}' escapelight.cpp:44:9: warning: unused variable 'dy' [-Wunused-variable] int dy[] = {-1, 1, 0, 0}; ^ escapelight.cpp: In function 'int main()': escapelight.cpp:96:16: error: expected unqualified-id before '[' token for (auto& [pos, _] : switch_map) { ^ escapelight.cpp:96:16: error: expected ';' before '[' token escapelight.cpp:96:17: error: 'pos' was not declared in this scope for (auto& [pos, _] : switch_map) { ^ escapelight.cpp:96:22: error: '_' was not declared in this scope for (auto& [pos, _] : switch_map) { ^ escapelight.cpp: In lambda function: escapelight.cpp:96:25: error: expected '{' before ':' token for (auto& [pos, _] : switch_map) { ^ escapelight.cpp: In function 'int main()': escapelight.cpp:96:25: error: expected ';' before ':' token escapelight.cpp:96:25: error: expected primary-expression before ':' token escapelight.cpp:96:25: error: expected ')' before ':' token escapelight.cpp:96:25: error: expected primary-expression before ':' token escapelight.cpp:96:25: error: expected ';' before ':' token escapelight.cpp:95:9: warning: unused variable 'id' [-Wunused-variable] int id = 0; ^ escapelight.cpp:105:1: error: expected '}' at end of input } ^
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ă.