Submission

Status:

[PPPPPPPPPPPPPPPPPPPPPPP-S]

Subtask/Task Score:

{0/100}

Score: 0

User: spiwips

Problemset: เกาะที่ใหญ่ที่สุด

Language: cpp

Time: 0.006 second

Submitted On: 2025-12-13 22:01:15

#include<bits/stdc++.h>

using namespace std;

int n,m;
int dir1[4] = {0,0,-1,1},dir2[4] = {-1,1,0,0};
char mp[175][175];
int vs[175][175];
int main(){
    
    queue<pair<int,int>> note;
    cin>>n>>m;
    //input stuff
    for(int i = 0 ; i < n; i ++)
    {
      for(int j = 0; j <m ; j++)
      {
        cin>>mp[i][j];    
      }
    }


    //loop stuff
    int max_size = 0;
    int counter = 0;
    pair<int,int> curr;
    for(int i = 0 ; i < n; i ++)
    {
      for(int j = 0; j <m ; j++)
      {
        //actual stuff
        if(vs[i][j] == 1){
          continue;
        }
        if(counter>max_size){
            max_size = counter;
        }
        counter = 0;
        note.push({i,j});
        vs[i][j] = 1;
        while(note.size()>0)
        {
          //go to close islands?
          
          curr = note.front();
          note.pop();
          for(int l = 0; l < 4; l++){
            int new_i = curr.first+dir1[l];
            int new_j = curr.second+dir2[l];
            //cout<<mp[new_i][new_j]<<'\n';
            //island check
            if(mp[new_i][new_j] == '1' && vs[new_i][new_j] == 0){
              ////cout<<counter<<'\n';
              vs[new_i][new_j] = 1;
              note.push({new_i,new_j});
              counter++;
              //cout<<"yay";
              
            }
            //end check
          }
          
       }
        //end of actual stuff
        
      }
    }
  cout<<max_size;
}