Advertisement
Negru_Diana

betasah

Feb 25th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<climits>
  4. using namespace std;
  5. ifstream fin("betasah.in");
  6. ofstream fout("betasah.out");
  7. int a[1003][1003];
  8. int di[]= {-1,0,1,0,-1,-1,1,1};
  9. int dj[]= {0,1,0,-1,-1, 1,1, -1};
  10. int ap[1003][1003];
  11. int i2[1003];
  12. int j2[1003];
  13. int main()
  14. {
  15. int n,i,j,nexti,nextj,i1,j1,D,K,l,p,cate=0,pmax=INT_MIN,k;
  16. fin>>n>>D>>K;
  17. for(i=1; i<=D; i++)
  18. {
  19. fin>>i1>>j1;
  20. i2[i]=i1;
  21. j2[i]=j1;
  22. a[i1][j1]=7;
  23. }
  24. for(i=1; i<=K; i++)
  25. {
  26. fin>>i1>>j1;
  27. a[i1][j1]=9;
  28. }
  29. for(i=0; i<=n+1; i++)
  30. {
  31. a[i][0]=3;
  32. a[n+1][i]=3;
  33. a[i][i+1]=3;
  34. a[i][i+2]=3;
  35. }
  36. // for(i=0;i<=n+1;i++)
  37. // {
  38. // for(j=0;j<=n+1;j++)
  39. // {
  40. // cout<<a[i][j]<<" ";
  41. // }
  42. // cout<<endl;
  43. // }
  44. for(i=1; i<=n+1; i++)
  45. {
  46. if(i==1)
  47. {
  48. j=1;
  49. }
  50. else
  51. {
  52. j++;
  53. }
  54. cate=0;
  55. for(p=1; p<=j; p++)
  56. {
  57. //cout<<a[i][p]<<" ";
  58. if(a[i][p]==3)
  59. {
  60. break;
  61. }
  62. if(a[i][p]!=9)
  63. {
  64. cate++;
  65. }
  66. //cout<<cate<<endl;
  67. }
  68. //cout<<endl;
  69. if(pmax<cate)
  70. {
  71. pmax=cate;
  72. }
  73. }
  74. fout<<pmax;
  75. for(p=1; p<=D; p++)
  76. {
  77. for(k=0; k<8; k++)
  78. {
  79. nexti=i2[p]+di[k];
  80. nextj=j2[p]+dj[k];
  81. a[nexti][nextj]=4;
  82. while(a[nexti][nextj]!=3 && a[nexti][nextj]!=9 && a[nexti][nextj]!=7)
  83. {
  84. nexti+=di[k];
  85. nextj+=dj[k];
  86. a[nexti][nextj]=4;
  87. }
  88. }
  89. }
  90. // for(i=0; i<=n+1; i++)
  91. // {
  92. // for(j=0; j<=n+1; j++)
  93. // {
  94. // cout<<a[i][j]<<" ";
  95. // }
  96. // cout<<endl;
  97. // }
  98. int patrate=0;
  99. for(i=1;i<=n;i++)
  100. {
  101. for(j=1;j<=n;j++)
  102. {
  103. if(a[i][j]==4)
  104. {
  105. patrate++;
  106. }
  107. }
  108. }
  109. fout<<patrate;
  110. return 0;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement