记录编号 351445 评测结果 AAAAAAAAAA
题目名称 删除他们! 最终得分 100
用户昵称 GravatarMealy 是否通过 通过
代码语言 C++ 运行时间 0.002 s
提交时间 2016-11-16 16:03:30 内存使用 0.31 MiB
显示代码纯文本
  1. /*
  2.  
  3. 2549. 删除他们!
  4.  
  5. deleteit.in
  6.  
  7. */
  8.  
  9.  
  10. #include <iostream>
  11. #include <cstdio>
  12.  
  13.  
  14. using namespace std;
  15.  
  16.  
  17. int n,m,q;
  18. int sx,sy,ex,ey;
  19.  
  20. int res;
  21. int lastx,lasty;
  22.  
  23.  
  24. void Delete(int sx,int sy,int ex,int ey)
  25. {
  26. if(sx==lastx&&ex==lastx&&sy>lasty)
  27. {
  28. return;
  29. }
  30. if(sx>lastx&&ex>lastx)
  31. {
  32. return;
  33. }
  34. if(ex>=lastx&&ey>=lasty)
  35. {
  36. if(sy<=lasty)
  37. {
  38. res-=lasty-sy+1;
  39. }
  40. res-=(lastx-sx)*(ey-sy+1);
  41. }
  42. else
  43. {
  44. res-=(min(lastx,ex)-sx+1)*(ey-sy+1);
  45. }
  46.  
  47. if(res%m==0)
  48. {
  49. lastx=res/m;
  50. }
  51. else
  52. {
  53. lastx=res/m+1;
  54. }
  55. lasty=res%m;
  56. if(lasty==0)
  57. {
  58. lasty=m;
  59. }
  60. // printf("%d %d %d\n",lastx,lasty,res);
  61. }
  62.  
  63.  
  64.  
  65.  
  66. void PreDo()
  67. {
  68. scanf("%d%d%d",&n,&m,&q);
  69. res=n*m;
  70. lastx=n;
  71. lasty=m;
  72. for(int i=1;i<=q;i++)
  73. {
  74. scanf("%d%d%d%d",&sx,&sy,&ex,&ey);
  75. sx++;
  76. sy++;
  77. ex++;
  78. ey++;
  79. Delete(sx,sy,ex,ey);
  80. }
  81. printf("%d\n",res);
  82. }
  83.  
  84.  
  85. int main()
  86. {
  87. freopen("deleteit.in","r",stdin);
  88. freopen("deleteit.out","w",stdout);
  89. PreDo();
  90. return 0;
  91. }