SHARE
TWEET

ugubagahs

a guest Jan 28th, 2020 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <fstream>
  2.  
  3. using namespace std;
  4. ifstream fin("regine.in");
  5. ofstream fout("regine.out");
  6. int a[102][102],x[501],y[501],n,m,i,j,namax,r,k,na,nr;
  7. int dx[8]={-1,-1,-1,0,1,1,1,0};
  8. int dy[8]={-1,0,1,1,1,0,-1,-1};
  9. int main()
  10. {
  11.     fin>>n>>m;
  12.     for(i=1;i<=m;i++)
  13.     {
  14.      fin>>x[i]>>y[i];
  15.      a[x[i]][y[i]]=1;
  16.     }
  17.     for(i=0;i<=n+1;i++)
  18.         a[i][0]=a[i][n+1]=a[0][i]=a[n+1][i]=-1;
  19.     namax=0;
  20.     for(r=1;r<=m;r++)
  21.     {
  22.         na=0;
  23.         for(k=0;k<8;k++)
  24.         {
  25.           i=x[r];j=y[r];
  26.           do{
  27.              i=i+dx[k];
  28.              j=j+dy[k];
  29.             }while(a[i][j]==0);
  30.             if(a[i][j]==1)na++;
  31.         }
  32.         if(na>namax)
  33.         {
  34.           namax=na;
  35.           nr=1;
  36.         }
  37.         else if(na==namax)nr++;
  38.     }
  39.     fout<<namax<<' '<<nr;
  40.     return 0;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top