QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#636059#7034. HoneycombpskkkCompile Error//C++231.4kb2024-10-12 22:02:302024-10-12 22:02:30

Judging History

你现在查看的是最新测评结果

  • [2024-10-12 22:02:30]
  • 评测
  • [2024-10-12 22:02:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int dx[6] = {-1, 1, -1, 1, 2, -2};
const int dy[6] = {-3, 3, 3, -3, 0, 0};
void solve() {
    int n, m;
    cin >> n >> m;
    n = n * 4 + 3;
    m = m * 6 + 3;
    vector<string> a(n);
    cin.getline(a[0], 6111);
    int sx, sy;
    for (int i = 0; i < n; ++i) {
        cin.getline(a[i], 6111);
        for (int j = 0; j < m; j++)
            if (a[i][j] == 'S')
                sx = i, sy = j;
    }
    auto bfs = [&](auto self) -> int {
        queue<tuple<int, int, int>> Q;
        Q.push({sx, sy, 1});
        a[sx][sy] = '*';
        while (!Q.empty()) {
            int x, y, d;
            tie(x, y, d) = Q.front();
            Q.pop();
            for (int o = 0; o < 6; o++) {
                int cx = x + dx[o], nx = cx + dx[o];
                int cy = y + dy[o], ny = cy + dy[o];
                if (nx < 0 || ny < 0 || nx >= n || ny >= m || a[cx][cy] != ' ' || a[nx][ny] == '*')
                    continue;
                if (a[nx][ny] == 'T')
                    return d + 1;
                a[nx][ny] = '*';
                Q.push({nx, ny, d + 1});
            }
        }
        return -1;
    };
    cout << bfs(bfs) << endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    cin >> T;
    while (T--) solve();
    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:11:16: error: no matching function for call to ‘std::basic_istream<char>::getline(__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type&, int)’
   11 |     cin.getline(a[0], 6111);
      |     ~~~~~~~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/13/sstream:40,
                 from /usr/include/c++/13/complex:45,
                 from /usr/include/c++/13/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:127,
                 from answer.code:1:
/usr/include/c++/13/istream:737:5: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::getline(char_type*, std::streamsize, char_type) [with _CharT = char; _Traits = std::char_traits<char>; char_type = char; std::streamsize = long int]’
  737 |     basic_istream<char>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/istream:737:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/13/istream:517:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::getline(char_type*, std::streamsize) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; char_type = char; std::streamsize = long int]’
  517 |       getline(char_type* __s, streamsize __n)
      |       ^~~~~~~
/usr/include/c++/13/istream:517:26: note:   no known conversion for argument 1 from ‘__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type’ {aka ‘std::__cxx11::basic_string<char>’} to ‘std::basic_istream<char>::char_type*’ {aka ‘char*’}
  517 |       getline(char_type* __s, streamsize __n)
      |               ~~~~~~~~~~~^~~
answer.code:14:20: error: no matching function for call to ‘std::basic_istream<char>::getline(__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type&, int)’
   14 |         cin.getline(a[i], 6111);
      |         ~~~~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/13/istream:737:5: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::getline(char_type*, std::streamsize, char_type) [with _CharT = char; _Traits = std::char_traits<char>; char_type = char; std::streamsize = long int]’
  737 |     basic_istream<char>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/istream:737:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/13/istream:517:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::getline(char_type*, std::streamsize) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; char_type = char; std::streamsize = long int]’
  517 |       getline(char_type* __s, streamsize __n)
      |       ^~~~~~~
/usr/include/c++/13/istream:517:26: note:   no known conversion for argument 1 from ‘__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type’ {aka ‘std::__cxx11::basic_string<char>’} to ‘std::basic_istream<char>::char_type*’ {aka ‘char*’}
  517 |       getline(char_type* __s, streamsize __n)
      |               ~~~~~~~~~~~^~~