比赛 202103省实验桐柏一中普及组联赛 评测结果 AAAAAAAAAA
题目名称 知己知彼,百战不殆 最终得分 100
用户昵称 䱖虁職 运行时间 0.177 s
代码语言 C++ 内存使用 14.08 MiB
提交时间 2021-03-22 19:03:41
显示代码纯文本
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int a[1801][1801]={0},n,m,ans=0,maxx=0,tot=0,tx[9]={0,1,2,2,1,-1,-2,-2,-1},ty[9]={0,2,1,-1,-2,-2,-1,1,2};
  4. int judge(int x,int y)
  5. {
  6. if(x<=n&&x>=1&&y<=n&&y>=1)
  7. return 1;
  8. return 0;
  9. }
  10. int main(){
  11. freopen("safenum.in","r",stdin);
  12. freopen("safenum.out","w",stdout);
  13. scanf("%d%d",&n,&m);
  14. for(int i=1;i<=m;i++)
  15. {
  16. int x,y;
  17. scanf("%d%d",&x,&y);
  18. a[x][y]++;
  19. for(int j=1;j<=8;j++)
  20. {
  21. if(judge(x+tx[j],y+ty[j]))
  22. {
  23. a[x+tx[j]][y+ty[j]]++;
  24. }
  25. }
  26. }
  27. for(int i=1;i<=n;i++)
  28. {
  29. for(int j=1;j<=n;j++)
  30. {
  31. if(a[i][j]!=0)
  32. {
  33. ans++;
  34. if(a[i][j]==maxx)
  35. {
  36. tot++;
  37. }
  38. else
  39. {
  40. if(a[i][j]>maxx)
  41. {
  42. tot=1;
  43. maxx=a[i][j];
  44. }
  45. }
  46. }
  47. }
  48. }
  49. ans=n*n-ans;
  50. printf("%d\n",ans);
  51. printf("%d %d",maxx,tot);
  52. return 0;
  53. }