fork download
  1. #include <iostream>
  2. #include <string.h>
  3. #include <vector>
  4. using namespace std;
  5. //堀江伸一 会津大学オンラインジャッジ問3422 Pyramid Planet
  6. struct E{
  7. int x,y,z;
  8. };
  9.  
  10. vector<E> vs;
  11. int memo[103][103][103];
  12.  
  13. int main() {
  14. int n,k;
  15. int ans=0;
  16. memset(memo,0,sizeof(memo));
  17. cin>>n>>k;
  18.  
  19. for(int i=0;i<n;i++){
  20. int x,y,z,h;
  21. E e1;
  22. cin>>x>>y>>z>>h;
  23. e1.x=x;
  24. e1.y=y;
  25. e1.z=z;
  26. vs.push_back(e1);
  27. for(int j=1;j<h;j++){
  28. memo[z+j][y-j][x-j]++;
  29. memo[z+j][y+j+1][x-j]--;
  30. memo[z+j][y-j][x+j+1]--;
  31. memo[z+j][y+j+1][x+j+1]++;
  32. }
  33. }
  34.  
  35.  
  36. for(int z=0;z<100;z++){
  37. for(int x=0;x<100;x++){
  38. int s1=0;
  39. for(int y=0;y<100;y++){
  40. s1+=memo[z][y][x];
  41. memo[z][y][x]=s1;
  42. }
  43. }
  44. }
  45.  
  46. for(int z=0;z<100;z++){
  47. for(int y=0;y<100;y++){
  48. int s1=0;
  49. for(int x=0;x<100;x++){
  50. s1+=memo[z][y][x];
  51. memo[z][y][x]=s1;
  52. }
  53. }
  54. }
  55. for(int i=0;i<vs.size();i++){
  56. E e1=vs[i];
  57. memo[e1.z][e1.y][e1.x]++;
  58. }
  59. //for(int z=0;z<4;z++){
  60. // for(int y=0;y<7;y++){
  61. // for(int x=0;x<7;x++){
  62. // if(k<=memo[z][y][x])ans++;
  63. // cout<<memo[z][y][x]<<" ";
  64. // }
  65. // cout<<endl;
  66. // }
  67. // cout<<endl;
  68. //}
  69. //cout<<endl;
  70.  
  71. for(int z=0;z<100;z++){
  72. for(int y=0;y<100;y++){
  73. for(int x=0;x<100;x++){
  74. if(k<=memo[z][y][x])ans++;
  75. }
  76.  
  77. }
  78.  
  79. }
  80. cout<<ans<<endl;
  81. return 0;
  82. }
Success #stdin #stdout 0.01s 7832KB
stdin
1 1
3 3 3 3
stdout
35