Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. for(i=1;i<=n;i++)
  2.         for(j=1;j<=m;j++)
  3.             if(a[i][j]==0) cnt++;
  4.     fout<<cnt<<"\n";
  5.     fout.close();
  6. }
  7.  
  8. void Cerinta2()
  9. {
  10.     int l,c,x,y,i,j,k,r;
  11.     for(l=1;l<=n;l++)
  12.         for(c=1;c<=m;c++)
  13.             if(a[l][c]!=0)
  14.             {
  15.                 r=a[l][c];
  16.                 v[r]++;
  17.                 a[l][c]=0;
  18.                 q.push(make_pair(l,c));
  19.  
  20.                 while(!q.empty())
  21.                 {
  22.                     x=q.front().first;
  23.                     y=q.front().second;
  24.                     q.pop();
  25.                     for(k=0;k<=3;k++)
  26.                     {
  27.                         i=x+dx[k];
  28.                         j=y+dy[k];
  29.                         if(a[i][j]==r)
  30.                         {
  31.                             q.push(make_pair(i,j));
  32.                             a[i][j]=0;
  33.  
  34.                         }
  35.                     }
  36.                 }
  37.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement