/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 5ms 4.496 MiB
#2 Accepted 4ms 4.27 MiB
#3 Accepted 5ms 4.496 MiB
#4 Accepted 5ms 4.27 MiB
#5 Accepted 6ms 4.5 MiB
#6 Accepted 9ms 4.523 MiB
#7 Time Exceeded ≥2097ms ≥7.973 MiB
#8 Time Exceeded ≥2098ms ≥8.066 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)
{
    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);
    dfs(i,j+1);
    dfs(i-1,j);
    dfs(i,j-1);
}
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];
        }
    }

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            dfs(i,j);
            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:17:57
Judged At
2024-11-11 03:43:22
Judged By
Score
60
Total Time
≥2098ms
Peak Memory
≥8.066 MiB