/ SeriousOJ /

Record Detail

Compile Error

foo.cc: In function 'int main()':
foo.cc:34:16: error: invalid conversion from 'int' to 'void*' [-fpermissive]
   34 |         memset(f, 0, sizeof f);
      |                ^
      |                |
      |                int
In file included from /usr/include/features.h:502,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/c++config.h:679,
                 from /usr/include/c++/13/bits/requires_hosted.h:31,
                 from /usr/include/c++/13/iostream:38,
                 from foo.cc:1:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:57:1: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   57 | __NTH (memset (void *__dest, int __ch, size_t __len))
      | ^~~~~
foo.cc:40:40: error: invalid types 'int[int]' for array subscript
   40 |                 if (s[i][j] == '0' && f[i][j] == 0) {
      |                                        ^

Code

#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

int t, n, m, cs, ans, c;
char s[2005][2005];
bool f[2005][2005];


void dfs(int x, int y) {
    if (x < 0 || y < 0 || x >= m || y >= n || s[x][y] == '1' || f[x][y]) return;
    f[x][y] = 1;
    c++;
    dfs(x + 1, y);
    dfs(x - 1, y);
    dfs(x, y + 1);
    dfs(x, y - 1);
}

int main() {

    int f = scanf("%d", &t);

    for (cs = 1; cs <= t; cs++) {
    
        cin >> m >> n;


        for (int i = 0; i < m; i++) {
            cin >> s[i];
        }

        memset(f, 0, sizeof f);

        ans = 0;        

        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (s[i][j] == '0' && f[i][j] == 0) {
                    c = 0;
                    dfs(i, j);
                    ans = max(ans, c);
                }
            } 
        }

        cout << "Floor #" << cs << ": " << ans << "\n";

    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1002 Office Space
Language
C++17 (G++ 13.2.0)
Submit At
2023-11-22 20:59:01
Judged At
2024-11-11 03:51:29
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes