/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 9ms 16.566 MiB
#2 Accepted 11ms 17.168 MiB
#3 Accepted 14ms 16.617 MiB
#4 Accepted 12ms 17.402 MiB
#5 Accepted 12ms 16.668 MiB
#6 Accepted 15ms 16.902 MiB
#7 Accepted 1440ms 19.617 MiB
#8 Accepted 1436ms 19.613 MiB
#9 Accepted 1433ms 19.617 MiB

Code

#include <string.h>
#include <stdio.h>

int t, n, m, cs, ans, c;
char s[2005][2005];
int 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() {

    scanf("%d", &t);

    for (cs = 1; cs <= t; cs++) {
    
        scanf("%d %d", &m, &n);


        for (int i = 0; i < m; i++) {
            scanf("%s", 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);
                    if (c > ans) ans = c;
                }
            } 
        }

        // cout << "Floor #" << cs << ": " << ans << "\n";
        printf("Floor #%d: %d\n", cs, ans);

    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1002 Office Space
Language
C99 (GCC 13.2.0)
Submit At
2023-11-22 21:40:50
Judged At
2024-11-11 03:51:21
Judged By
Score
100
Total Time
1440ms
Peak Memory
19.617 MiB