Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int a[101][101],nrel,b[101][101],c[101][101];
- void scrie(int x,int y,int d[101][101])///el)
- {
- if(d[x][y]==0)///==el
- {
- d[x][y]=1; ///-1
- nrel++;
- scrie(x+1,y,d);
- scrie(x,y+1,d);
- scrie(x-1,y,d);
- scrie(x,y-1,d);
- }
- }
- int main()
- {
- int n,m;
- cin>>n>>m;
- for(int i=1;i<=n;i++)
- {
- for(int j=1;j<=m;j++)
- {
- cin>>a[i][j];
- b[i][j]=a[i][j];
- }
- }
- for(int i=1;i<=n;i++)
- {
- a[i][0]=a[i][m+1]=1;
- }
- for(int j=1;j<=m;j++)
- {
- a[0][j]=a[n+1][j]=1;
- }
- for(int i=1;i<=n;i++)
- {
- c[i][0]=c[i][m+1]=1;
- }
- for(int j=1;j<=m;j++)
- {
- c[0][j]=c[n+1][j]=1;
- }
- int nr=0,nrmax=0;
- for(int i=1;i<=n;i++)
- {
- for(int j=1;j<=m;j++)
- {
- if(a[i][j]==0)///!-1 el=a[i][j]
- {
- nrel=0;
- scrie(i,j,a);///el
- nr++;
- if(nrel>nrmax)
- nrmax=nrel;
- }
- }
- }
- cout<<nr<<" "<<nrmax;
- nrmax=0;
- int lin,col;
- for(int i=1;i<=n;i++)
- {
- for(int j=1;j<=m;j++)
- {
- if(b[i][j]==1)
- {
- for(int p=1;p<=n;p++)
- {
- for(int q=1;q<=m;q++)
- {
- c[p][q]=b[p][q];
- }
- }
- nrel=0;
- c[i][j]=0;
- scrie(i,j,c);
- //cout<<nrel<<endl;
- if(nrel>nrmax)
- {
- nrmax=nrel;
- lin=i;
- col=j;
- }
- }
- }
- }
- cout<<nrmax<<" "<<lin<<" "<<col;
- /*for(int i=1;i<=n;i++)
- {
- for(int j=1;j<=m;j++)
- {
- cout<<a[i][j]<<" ";
- }
- cout<<endl;
- }*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement