Advertisement
nicuvlad76

Untitled

Feb 25th, 2023
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <fstream>
  2. #include <algorithm>
  3. #include <cmath>
  4. #define N 1005
  5. using namespace std;
  6. ifstream fin("romburi.in");
  7. ofstream fout("romburi.out");
  8. bool a[N][N];
  9. int n,m,p, x,y,l, i,j;
  10. int nr;
  11. int xc,yc,d;
  12. int main() {
  13.  
  14. fin>>n>>m>>p;
  15. while(p>0)
  16. {
  17. p--;
  18. fin>>x>>y>>l;
  19. a[x][y]=1;
  20. xc=x;
  21. yc=y;
  22. d=2*l-1;
  23. for(i=1;i<=d-2;i+=2)
  24. {
  25. for(j=yc; j<=yc+i-1;j++)
  26. if(xc>=1 && xc<=n && j>=1 && j<=m)
  27. a[xc][j]=1;
  28. yc--;
  29. xc++;
  30. }
  31. for(i=d;i>=1;i-=2)
  32. {
  33. for(j=yc; j<=yc+i-1;j++)
  34. if(xc>=1 && xc<=n && j>=1 && j<=m)
  35. a[xc][j]=1;
  36. yc++;
  37. xc++;
  38. }
  39.  
  40. }
  41.  
  42. for(i=1;i<=n;i++)
  43. for(j=1;j<=m;j++)
  44. if(a[i][j]==0)nr++;
  45. fout<<nr;
  46. return 0;
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement