Problem p01712 (C++) — buggy submission, verdict: Memory Limit Exceeded

#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int main() {
  vector<int> map_x, map_y;
  int N;
  int map_x_size, map_y_size;
  int x, y, w;
  cin >> N >> map_x_size >> map_y_size;
  map_x_size *= 2;
  map_y_size *= 2;
  map_x_size++;
  map_y_size++;
  map_x.resize(map_x_size + 1);
  map_y.resize(map_y_size + 1);
  for (size_t i = 0; i < N; i++) {
    cin >> x >> y >> w;
    x *= 2;
    y *= 2;
    w *= 2;
    map_x[max(0, x - w)]++;
    map_x[min(x + w + 1, map_x_size)]--;
    map_y[max(0, y - w)]++;
    map_y[min(y + w + 1, map_y_size)]--;
  }
  bool f1 = 1, f2 = 1;
  for (size_t i = 0; i < map_x_size; i++) {
    if (i) {
      map_x[i] += map_x[i - 1];
    }
    if (map_x[i] < 1) {
      f2 = 0;
    }
  }

  for (size_t i = 0; i < map_y_size; i++) {
    if (i) {
      map_y[i] += map_y[i - 1];
    }
    if (map_y[i] < 1) {
      f1 = 0;
    }
  }
  cout << (f1 || f2 ? "Yes" : "No") << endl;
  return 0;
}

Error: MLE

Fixed submission:

#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

int main() {
  vector<vector<bool>> map;
  int x, y, w;
  int N, x_map, y_map;
  cin >> N >> x_map >> y_map;
  x_map++;
  y_map++;
  map.resize(x_map);
  for (size_t i = 0; i < x_map; i++) {
    map[i].resize(y_map);
    for (size_t j = 0; j < y_map; j++) {
      map[i][j] = true;
    }
  }
  for (size_t i = 0; i < N; i++) {
    cin >> x >> y >> w;
    for (size_t j = max(x - w, 0); j <= min(x + w, x_map - 1); j++) {
      for (size_t k = 0; k < y_map; k++) {

        map[j][k] = 0;
      }
    }
    for (size_t j = max(y - w, 0); j <= min(y + w, y_map - 1); j++) {
      for (size_t k = 0; k < x_map; k++) {

        map[k][j] = 0;
      }
    }
  }
  for (auto x : map) {
    for (auto y : x) {
      if (y) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}