Advertisement
Guest User

Untitled

a guest
May 29th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<algorithm>
  3. using namespace std;
  4. main()
  5. {
  6. int time,i,x,y,x1,x2,y1,y2,val;
  7. scanf("%d",&time);
  8. while(time--)
  9. {
  10. scanf("%d%d%d",&n,&m,&k);
  11. for(i=0;i<n;i++)
  12. {
  13. for(x=0;x<m;x++)
  14. {
  15. for(y=0;y<k;y++)
  16. {
  17. scanf("%d",&val);
  18. sum[i][x][y] = val + sum[i][x-1][y] + sum[i][x][y-1] - sum[i][x-1][y-1];
  19. }
  20. }
  21. }
  22. for(i=0;i<n;i++)
  23. {
  24. for(x1=0;x1<m;x1++)
  25. {
  26. for(y1=0;y1<k;y1++)
  27. {
  28. for(x2=x1;x2<m;x2++)
  29. {
  30. for(y2=y1;y2<k;y2++)
  31. {
  32. mem[flag][x1][y1][x2][y2] = max(0,mem[!flag][x1][y1][x2][y2]) + sum[i][x2][y2] - sum[i][x1-1][y2] - sum[i][x2][y1-1] + sum[i][x1-1][x2-1];
  33. }
  34. }
  35. }
  36. }
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement