SHARE
TWEET

Untitled

a guest Jan 28th, 2020 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. ifstream fin("regine.in");
  4. ofstream fout("regine.out");
  5. int n,i,j,a[102][102],m,x[501],y[501],nrmv,nrr,u,v,nrv,k;
  6. int dx[8]={-1,-1,0,1,1,1,0,-1};
  7. int dy[8]={0,1,1,1,0,-1,-1,-1};
  8. int main()
  9. {
  10.     fin>>n>>m;
  11.     for(i=1;i<=m;i++)
  12.     {
  13.         fin>>x[i]>>y[i];
  14.         a[x[i]][y[i]]=1;
  15.     }
  16.     for(i=0;i<=n+1;i++)
  17.         a[i][0]=a[n+1][i]=a[i][n+1]=a[0][i]=-1;
  18.     nrmv=0;
  19.     nrr=0;
  20.     for(i=1;i<=m;i++)
  21.     {
  22.         nrv=0;
  23.         for(k=0;k<8;k++)
  24.         {
  25.             u=x[i];
  26.             v=y[i];
  27.             do{
  28.                 u=u+dx[k];
  29.                 v=v+dy[k];
  30.             }while(a[u][v]==0);
  31.             if(a[u][v]==1)
  32.                 nrv++;
  33.         }
  34.         if(nrv>nrmv)
  35.         {
  36.             nrmv=nrv;
  37.             nrr=1;
  38.         }
  39.         else
  40.             if(nrv==nrmv)
  41.                 nrr++;
  42.     }
  43.     fout<<nrmv<<' '<<nrr;
  44.     return 0;
  45. }
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