QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#440078#8742. 黑白james1BadCreeperCompile Error//C++231.1kb2024-06-13 07:19:212024-06-13 07:19:22

Judging History

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

  • [2024-06-13 07:19:22]
  • 评测
  • [2024-06-13 07:19:21]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int N = 1e3 + 5; 
const int D[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}}; 

int n, m; 
bool vis[N][N]; 
char a[N][N]; 

void bfs(int x, int y) {
    vis[x][y] = 1; 
    for (int i = 0; i < 4; ++i) {
        int xx = x + D[i][0], yy = y + D[i][1]; 
        if (xx >= 1 && xx <= n && yy >= 1 && yy <= m && !vis[xx][yy] && a[xx][yy] == 'W') 
            bfs(xx, yy); 
    }
}

void solve(void) {
    cin >> n >> m; 
    for (int i = 1; i <= n; ++i) cin >> a[i] + 1; 
    for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) vis[i][j] = 0; 
    bfs(1, 1); 
    if (!vis[n][m]) return cout << "J\n", void(); 
    int ans = 0; 
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            ans += (a[i][j] == 'W'); 
    // cerr << ans << "\n"; 
    if ((ans - (n + m - 1)) & 1) cout << "I\n"; 
    else cout << "J\n"; 
}

int main(void) {
    ios::sync_with_stdio(0); cin.tie(0); 
    int T = 1; cin >> T; 
    while (T--) solve();
    return 0;
}

Details

answer.code: In function ‘void solve()’:
answer.code:22:38: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’)
   22 |     for (int i = 1; i <= n; ++i) cin >> a[i] + 1;
      |                                  ~~~ ^~ ~~~~~~~~
      |                                  |           |
      |                                  |           char*
      |                                  std::istream {aka std::basic_istream<char>}
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:325:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  325 |       operator>>(void*& __p)
      |       ^~~~~~~~
/usr/include/c++/13/istream:325:7: note:   conversion of argument 1 would be ill-formed:
answer.code:22:46: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’
   22 |     for (int i = 1; i <= n; ++i) cin >> a[i] + 1;
      |                                         ~~~~~^~~
/usr/include/c++/13/istream:201:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  201 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:201:7: note:   conversion of argument 1 would be ill-formed:
answer.code:22:46: error: invalid conversion from ‘char*’ to ‘long long unsigned int’ [-fpermissive]
   22 |     for (int i = 1; i <= n; ++i) cin >> a[i] + 1;
      |                                         ~~~~~^~~
      |                                              |
      |                                              char*
answer.code:22:46: error: cannot bind rvalue ‘(long long unsigned int)(((char*)(& a[i])) + 1)’ to ‘long long unsigned int&’
/usr/include/c++/13/istream:197:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  197 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:197:7: note:   conversion of argument 1 would be ill-formed:
answer.code:22:46: error: invalid conversion from ‘char*’ to ‘long long int’ [-fpermissive]
   22 |     for (int i = 1; i <= n; ++i) cin >> a[i] + 1;
      |                                         ~~~~~^~~
      |                                              |
      |                                              char*
answer.code:22:46: error: cannot bind rvalue ‘(long long int)(((char*)(& a[i])) + 1)’ to ‘long long int&’
/usr/include/c++/13/istream:192:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  192 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:192:7: note:   conversion of argument 1 would be ill-formed:
answer.code:22:46: error: invalid conversion from ‘char*’ to ‘long unsigned int’ [-fpermissive]
   22 |     for (int i = 1; i <= n; ++i) cin >> a[i] + 1;
      |                                         ~~~~~^~~
      |                                              |
      |                                              char*
answer.code:22:46: error: cannot bind rvalue ‘(long unsigned int)(((char*)(& a[i])) + 1)’ to ‘long unsigned int&’
/usr/include/c++/13/istream:188:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]’ (near match)
  188 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/13/istream:188:7: note:   conversion of argument 1 would be ill-formed:
answer.code:22:46: error: invalid conversion from ‘char*’ to ‘long int’ [-fpermissive]
   22 |     for (int i = 1; i <= n; ++i) cin >> a[i] + 1;
      |                                         ~~~~~^~~
      |                                              |
      |                                              char*
answer.code:22:46: error: cannot bind rvalue ‘(long int)(((char*)(& a[i])) + 1)’ to ‘long int&’
/usr/include/c++/13/istream:184:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istrea...