/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 5ms 5.527 MiB
#2 Accepted 5ms 5.531 MiB
#3 Accepted 6ms 5.812 MiB
#4 Accepted 5ms 4.41 MiB
#5 Accepted 6ms 6.027 MiB
#6 Accepted 9ms 6.387 MiB
#7 Time Exceeded ≥2056ms ≥8.207 MiB
#8 Time Exceeded ≥2086ms ≥8.039 MiB

Code

#include <iostream>
#include <cstring>
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() {

    cin >> 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
2024-02-14 12:59:16
Judged At
2024-11-11 03:43:13
Judged By
Score
60
Total Time
≥2086ms
Peak Memory
≥8.207 MiB