#3114
abq
Fie o matrice cu n
linii (numerotate de la 1
la n
) și m
coloane (numerotate de la 1
la m
) ce conține doar literele a
și b
. Se definește un drum de la o poziție (xs, ys)
la o alta (xf, yf)
ca fiind o succesiune de pași care pornește din coordonatele (xs, ys)
și ajunge în (xf, yf)
și care trece numai prin componente care memorează litera a
. La fiecare pas, de la o poziţie (i, j)
se poate trece într-una din poziţiile (i+1, j)
, (i-1, j)
, (i, j+1)
, (i, j-1)
. Lungimea drumului este dată de numărul de componente care compun drumul.
Având la dispoziție q
întrebări date sub forma a patru numere naturale xs ys xf yf
, trebuie să răspundeți pentru fiecare întrebare care este lungimea minimă a unui drum de la (xs, ys)
la (xf, yf)
care trece numai prin componente ce memorează litera a
. Dacă un astfel de drum nu există, veți afișa valoarea –1
.
Concurs Judetean XOR 2014
Problema | abq | Operații I/O |
abq.in /abq.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 4 MB
/
Stivă 2 MB
|
Id soluție | #53574228 | Utilizator | |
Fișier | abq.cpp | Dimensiune | 2.23 KB |
Data încărcării | 05 Noiembrie 2024, 14:41 | Scor / rezultat | Eroare de compilare |
abq.cpp: In function 'void Lee(int, int, int, int)': abq.cpp:17:12: error: reference to 'distance' is ambiguous memset(distance, 0, sizeof(distance)); ^ abq.cpp:13:5: note: candidates are: int distance [201][201] int distance[201][201]; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:66:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from abq.cpp:1: /usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:114:5: note: template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator) distance(_InputIterator __first, _InputIterator __last) ^ abq.cpp:17:32: error: reference to 'distance' is ambiguous memset(distance, 0, sizeof(distance)); ^ abq.cpp:13:5: note: candidates are: int distance [201][201] int distance[201][201]; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:66:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from abq.cpp:1: /usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:114:5: note: template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator) distance(_InputIterator __first, _InputIterator __last) ^ abq.cpp:21:5: error: reference to 'distance' is ambiguous distance[startX][startY] = 0; // Starting position has a distance of 0 ^ abq.cpp:13:5: note: candidates are: int distance [201][201] int distance[201][201]; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:66:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from abq.cpp:1: /usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:114:5: note: template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator) distance(_InputIterator __first, _InputIterator __last) ^ abq.cpp:35:17: error: reference to 'distance' is ambiguous distance[newX][newY] = distance[i][j] + 1; ^ abq.cpp:13:5: note: candidates are: int distance [201][201] int distance[201][201]; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:66:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from abq.cpp:1: /usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:114:5: note: template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator) distance(_InputIterator __first, _InputIterator __last) ^ abq.cpp:35:40: error: reference to 'distance' is ambiguous distance[newX][newY] = distance[i][j] + 1; ^ abq.cpp:13:5: note: candidates are: int distance [201][201] int distance[201][201]; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:66:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from abq.cpp:1: /usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:114:5: note: template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator) distance(_InputIterator __first, _InputIterator __last) ^ abq.cpp: In function 'int main()': abq.cpp:65:17: error: reference to 'distance' is ambiguous if (distance[end_i][end_j] != 0 || (start_i == end_i && start_j == end_j)) { ^ abq.cpp:13:5: note: candidates are: int distance [201][201] int distance[201][201]; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:66:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from abq.cpp:1: /usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:114:5: note: template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator) distance(_InputIterator __first, _InputIterator __last) ^ abq.cpp:66:24: error: reference to 'distance' is ambiguous out << distance[end_i][end_j] << '\n'; // Output the distance to target ^ abq.cpp:13:5: note: candidates are: int distance [201][201] int distance[201][201]; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:66:0, from /usr/include/c++/4.8/bits/char_traits.h:39, from /usr/include/c++/4.8/ios:40, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/sstream:38, from /usr/include/c++/4.8/complex:45, from /usr/include/c++/4.8/ccomplex:38, from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52, from abq.cpp:1: /usr/include/c++/4.8/bits/stl_iterator_base_funcs.h:114:5: note: template<class _InputIterator> typename std::iterator_traits<_Iterator>::difference_type std::distance(_InputIterator, _InputIterator) distance(_InputIterator __first, _InputIterator __last) ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema abq 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ă.