/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 4ms 996.0 KiB
#2 Accepted 4ms 1.074 MiB
#3 Accepted 4ms 1004.0 KiB
#4 Accepted 5ms 1.07 MiB
#5 Accepted 6ms 1.281 MiB
#6 Accepted 10ms 1.312 MiB
#7 Time Exceeded ≥2097ms ≥4.957 MiB
#8 Time Exceeded ≥2059ms ≥4.949 MiB

Code

#include<bits/stdc++.h>
using namespace std;
char grid[2001][2001];
//bool vis[2001][2001];
int n,m,room=0,mx=0;
bool ok=false;
void dfs(int i,int j,vector<vector<bool>> &vis)
{
    if(i<0 || j<0) return;
    if(i>=n || j>=m) return;
    if(vis[i][j]) return;
    if(grid[i][j]=='1') return;

    ++room;
    vis[i][j]=true;
    dfs(i+1,j,vis);
    dfs(i,j+1,vis);
    dfs(i-1,j,vis);
    dfs(i,j-1,vis);
}

void solve(int tc)
{
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++) 
        {
            cin>>grid[i][j];
        }
    }
    
    vector<vector<bool>>vis(2001,vector<bool>(2001));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            dfs(i,j,vis);
            mx=max(mx,room);
            room=0;
        }
    }
    
    cout<<"Floor #"<<tc<<": ";
    cout<<mx<<endl;
    mx=0;
}

int main()
{
    int t; cin>>t;
    for(int i=1;i<=t;i++)
    {
        solve(i);
        /*for(int i=0;i<=2000;i++)
        {
            for(int j=0;j<=2000;j++)
            {
                vis[i][j]=false;
            }
        }*/
    }
}

Information

Submit By
Type
Submission
Problem
P1002 Office Space
Language
C++20 (G++ 13.2.0)
Submit At
2024-02-07 08:32:18
Judged At
2024-11-11 03:43:22
Judged By
Score
60
Total Time
≥2097ms
Peak Memory
≥4.957 MiB