Problem p00503 (C++) — buggy submission, verdict: Runtime Error

#include "stdio.h"
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>

using namespace std;

int q[55][2][3];

long long int xx[111];
long long int yy[111];
long long int zz[111];

int w[111][111][111];

int main() {
  int n, k;
  scanf("%d %d", &n, &k);

  priority_queue<int, vector<int>, greater<int>> x, y, z;

  for (int i = 0; i < n; i++) {
    scanf("%d %d %d %d %d %d", &q[i][0][0], &q[i][0][1], &q[i][0][2],
          &q[i][1][0], &q[i][1][1], &q[i][1][2]);
    x.push(q[i][0][0]);
    x.push(q[i][1][0]);
    y.push(q[i][0][1]);
    y.push(q[i][1][1]);
    z.push(q[i][0][2]);
    z.push(q[i][1][2]);
  }

  int xw = 0;
  int yw = 0;
  int zw = 0;
  int mae;
  mae = -1;
  while (x.empty() == false) {
    if (mae != x.top()) {
      xx[xw] = x.top();
      mae = x.top();
      xw++;
    }
    x.pop();
  }
  mae = -1;
  while (y.empty() == false) {
    if (mae != y.top()) {
      yy[yw] = y.top();
      mae = y.top();
      yw++;
    }
    y.pop();
  }
  mae = -1;
  while (z.empty() == false) {
    if (mae != z.top()) {
      zz[zw] = z.top();
      mae = z.top();
      zw++;
    }
    z.pop();
  }

  for (int i = 0; i < xw; i++) {
    for (int ii = 0; ii < yw; ii++) {
      for (int iii = 0; iii < zw; iii++) {
        w[i][ii][iii] = 0;
      }
    }
  }

  for (int j = 0; j < n; j++) {
    for (int i = 0; i < xw; i++) {
      for (int ii = 0; ii < yw; ii++) {
        for (int iii = 0; iii < zw; iii++) {
          if (q[j][0][0] <= xx[i] && xx[i] < q[j][1][0] &&
              q[j][0][1] <= yy[ii] && yy[ii] < q[j][1][1] &&
              q[j][0][2] <= zz[iii] && zz[iii] < q[j][1][2]) {
            w[i][ii][iii]++;
          }
        }
      }
    }
  }

  long long int all = 0;
  for (int i = 0; i < xw; i++) {
    for (int ii = 0; ii < yw; ii++) {
      for (int iii = 0; iii < zw; iii++) {
        if (w[i][ii][iii] >= k) {
          all += (xx[i + 1] - xx[i]) * (yy[ii + 1] - yy[ii]) *
                 (zz[iii + 1] - zz[iii]);
        }
      }
    }
  }

  printf("%lld\\n", all);

  return 0;
}

Error: 0

Fixed submission:

#include "stdio.h"
#include <algorithm>
#include <functional>
#include <iostream>
#include <queue>

using namespace std;

int q[55][2][3];

int xx[55];
int yy[55];
int zz[55];

int w[55][55][55];

int main() {
  int n, k;
  scanf("%d %d", &n, &k);

  priority_queue<int, vector<int>, greater<int>> x, y, z;

  for (int i = 0; i < n; i++) {
    scanf("%d %d %d %d %d %d", &q[i][0][0], &q[i][0][1], &q[i][0][2],
          &q[i][1][0], &q[i][1][1], &q[i][1][2]);
    x.push(q[i][0][0]);
    x.push(q[i][1][0]);
    y.push(q[i][0][1]);
    y.push(q[i][1][1]);
    z.push(q[i][0][2]);
    z.push(q[i][1][2]);
  }

  int xw = 0;
  int yw = 0;
  int zw = 0;
  int mae;
  mae = -1;
  while (x.empty() == false) {
    if (mae != x.top()) {
      xx[xw] = x.top();
      mae = x.top();
      xw++;
    }
    x.pop();
  }
  mae = -1;
  while (y.empty() == false) {
    if (mae != y.top()) {
      yy[yw] = y.top();
      mae = y.top();
      yw++;
    }
    y.pop();
  }
  mae = -1;
  while (z.empty() == false) {
    if (mae != z.top()) {
      zz[zw] = z.top();
      mae = z.top();
      zw++;
    }
    z.pop();
  }

  for (int i = 0; i < xw; i++) {
    for (int ii = 0; ii < yw; ii++) {
      for (int iii = 0; iii < zw; iii++) {
        w[i][ii][iii] = 0;
      }
    }
  }

  for (int j = 0; j < n; j++) {
    for (int i = 0; i < xw; i++) {
      for (int ii = 0; ii < yw; ii++) {
        for (int iii = 0; iii < zw; iii++) {
          if (q[j][0][0] <= xx[i] && xx[i] < q[j][1][0] &&
              q[j][0][1] <= yy[ii] && yy[ii] < q[j][1][1] &&
              q[j][0][2] <= zz[iii] && zz[iii] < q[j][1][2]) {
            w[i][ii][iii]++;
          }
        }
      }
    }
  }

  long long int all = 0;
  for (int i = 0; i < xw; i++) {
    for (int ii = 0; ii < yw; ii++) {
      for (int iii = 0; iii < zw; iii++) {
        if (w[i][ii][iii] >= k) {
          all += (xx[i + 1] - xx[i]) * (yy[ii + 1] - yy[ii]) *
                 (zz[iii + 1] - zz[iii]);
        }
      }
    }
  }

  printf("%lld\\n", all);

  return 0;
}