alexjercan/bugnet huggingface dataset:
Problem p01711 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bitset>
#include <iostream>
#include <string>
using namespace std;
constexpr int dx[] = {1, 0, 1, 0, -1, 0, -1}, dy[] = {0, -1, 1, 0, -1, 1, 0},
              x = ((1LL << 3) | (1LL << 4) | (1LL << 9) | (1LL << 15) |
                   (1LL << 20) | (1LL << 21));

int filter(const int &t, const string &s) {
  int ret = (t & (31 | (31 << 20)));
  for (int i = 1; i < 4; ++i) {
    ret |= (t & (17 << (5 * i)));
    for (int j = 1; j < 4; ++j) {
      int u = 0;
      for (int k = 0; k < 7; ++k) {
        int x = i + dx[k], y = j + dy[k];
        u |= (((t >> (x * 5 + y)) & 1) << k);
      }
      ret |= ((s[u] - '0') << (5 * i + j));
    }
  }
  return ret;
}

bool filter2(const int &t, const string &s) {
  int i = 2, j = 2, u = 0;
  for (int k = 0; k < 7; ++k) {
    int x = i + dx[k], y = j + dy[k];
    u |= (((t >> (x * 5 + y)) & 1) << k);
  }
  return (s[u] - '0' == ((t >> 12) & 1));
}

bool check(const int &t, const string &s) {
  int u = filter(t, s);
  return filter2(u, s);
}

signed main() {
  string s;
  while (cin >> s, s != "#") {
    string ans = "yes";
    for (int i = 0; i < (1LL << 25); i = ((i + 1) | x)) {
      if (!check(i, s)) {
        ans = "no";
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bitset>
#include <iostream>
#include <vector>
#define int long long
using namespace std;
const int dx[] = {1, 0, -1, 0, -1, 0, 1}, dy[] = {0, -1, -1, 0, 0, 1, 1},
          x = ((1LL << 3) | (1LL << 4) | (1LL << 9) | (1LL << 15) |
               (1LL << 20) | (1LL << 21));

int filter(int t, string s) {
  int ret = (t & (31 | (31LL << 20)));
  for (int i = 1; i < 4; ++i) {
    ret |= (((t >> (5 * i)) & 17) << (5 * i));
    for (int j = 1; j < 4; ++j) {
      int u = 0;
      for (int k = 0; k < 7; ++k) {
        int x = i + dx[k], y = j + dy[k];
        u |= (((t >> (x * 5 + y)) & 1) << k);
      }
      // cout << i << " " << j << " " << bitset<7>(u) << endl;
      ret |= ((s[u] - '0') << (5 * i + j));
    }
  }
  return ret;
}

bool check(int t, string s) {
  // cout << bitset<25>(t) << endl;//" " << bitset<25>(u) << " " <<
  // bitset<25>(filter(u,s)) << endl;
  int u = filter(t, s);
  return u == filter(u, s);
}

signed main() {
  string s;
  while (cin >> s, s != "#") {
    string ans = "yes";
    for (int i = 0; i < (1LL << 25); ++i) { // i = ((i+1)|(x))){
      if (!check(i, s)) {
        ans = "no";
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p01712 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <vector>

#include <cstdio>

using namespace std;

bool check(vector<int> const &covered_coord) {
  int lim = covered_coord[0] + 1;
  for (int i = 1; i < covered_coord.size() && i <= lim; i++) {
    lim = max(lim, covered_coord[i] + 1);
  }

  return lim == covered_coord.size();
}

int main(void) {
  int n, w, h;
  cin >> n >> w >> h;
  vector<int> x_covered(w, -1), y_covered(h, -1);

  for (int i = 0; i < n; i++) {
    int x, y, koto;
    scanf("%d %d %d", &x, &y, &koto);

    int min_coord = max(0, -koto + x), max_coord = min(w - 1, koto - 1 + x);
    x_covered[min_coord] = max(x_covered[min_coord], max_coord);

    min_coord = max(0, -koto + y), max_coord = min(h - 1, koto - 1 + y);
    y_covered[min_coord] = max(y_covered[min_coord], max_coord);
  }

  cout << (check(x_covered) || check(y_covered) ? "Yes" : "No") << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#include <cstdint>
#include <cstdio>

using namespace std;

int main(void) {
  int n, w, h;
  cin >> n >> w >> h;

  list<int> x_coords(w), y_coords(h);
  iota(x_coords.begin(), x_coords.end(), 0);
  iota(y_coords.begin(), y_coords.end(), 0);

  for (int i = 0; i < n; i++) {
    int x, y, koto;
    scanf("%d %d %d", &x, &y, &koto);

    auto min = -koto + x, max = koto - 1 + x;
    auto first = x_coords.begin();
    while (first != x_coords.end() && *first < min)
      ++first;
    if (*first <= max && first != x_coords.end()) {
      auto last = next(first);
      while (last != x_coords.end() && *last <= max)
        last++;
      x_coords.erase(first, last);
      if (x_coords.empty())
        break;
    }

    min = -koto + y, max = koto - 1 + y;
    first = y_coords.begin();
    while (first != y_coords.end() && *first < min)
      ++first;
    if (*first <= max && first != y_coords.end()) {
      auto last = next(first);
      while (last != y_coords.end() && *last <= max)
        last++;
      y_coords.erase(first, last);
      if (y_coords.empty())
        break;
    }
  }

  cout << ((x_coords.empty() || y_coords.empty()) ? "Yes" : "No") << endl;

  return 0;
}
Problem p01712 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, w, h;
  cin >> n >> w >> h;
  vector<int> hrz(w + 2, 0), vrt(h + 2, 0);
  for (int i = 0; i < n; i++) {
    int x, y, p;
    cin >> x >> y >> p;
    hrz[max(x - p + 1, 0)] += 1;
    hrz[min(x + p + 1, w + 1)] -= 1;
    vrt[max(y - p + 1, 0)] += 1;
    vrt[min(y + p + 1, h + 1)] -= 1;
  }

  bool hyes = true, vyes = true;
  for (int i = 1; i <= w; i++) {
    hrz[i] += hrz[i - 1];
    if (hrz[i] == 0) {
      hyes = false;
      break;
    }
  }
  for (int i = 1; i <= h; i++) {
    vrt[i] += vrt[i - 1];
    if (vrt[i] == 0) {
      vyes = false;
      break;
    }
  }

  if (hyes || vyes) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, w, h;
  cin >> n >> w >> h;
  vector<int> hrz(w + 1, 0), vrt(h + 1, 0);
  for (int i = 0; i < n; i++) {
    int x, y, p;
    cin >> x >> y >> p;
    hrz[x - p + 1] += 1;
    hrz[x + p] -= 1;
    vrt[y - p + 1] += 1;
    vrt[y + p] -= 1;
  }

  bool hyes = true, vyes = true;
  for (int i = 1; i < w; i++) {
    hrz[i] += hrz[i - 1];
    if (hrz[i] == 0) {
      hyes = false;
      break;
    }
  }
  for (int i = 1; i < h; i++) {
    vrt[i] += vrt[i - 1];
    if (vrt[i] == 0) {
      vyes = false;
      break;
    }
  }

  if (hyes || vyes) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
Problem p01712 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

int n, w, h;

int r(int a, int b) {
  int c = a + b;
  if (c < 0)
    return 0;
  else if (c > h)
    return h;
  else
    return c;
}

int main(void) {
  cin >> n >> w >> h;
  vector<int> x(n), y(n), z(n);
  for (int i = 0; i < n; i++)
    cin >> x[i] >> y[i] >> z[i];

  vector<int> gh(h + 1, 0);
  vector<int> gw(w + 1, 0);
  for (int i = 0; i < n; i++) {
    gh[r(y[i], z[i] * -1)]++;
    gh[r(y[i], z[i])]--;
  }
  for (int i = 0; i < n; i++) {
    gw[r(x[i], z[i] * -1)]++;
    gw[r(x[i], z[i])]--;
  }

  for (int i = 0; i < h; i++)
    gh[i + 1] += gh[i];
  for (int i = 0; i < w; i++)
    gw[i + 1] += gw[i];

  bool f1 = true, f2 = true;
  for (int i = 0; i < h; i++)
    if (gh[i] == 0)
      f1 = false;
  for (int i = 0; i < w; i++)
    if (gw[i] == 0)
      f2 = false;
  if (f1 || f2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Error: 0

Fixed submission:

#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

int n, w, h;

int r(int a, int b) {
  int c = a + b;
  if (c < 0)
    return 0;
  else if (c > h)
    return h;
  else
    return c;
}

int main(void) {
  cin >> n >> w >> h;
  vector<int> x(n), y(n), z(n);
  for (int i = 0; i < n; i++)
    cin >> x[i] >> y[i] >> z[i];

  vector<vector<int>> g(h, vector<int>(w, 0));
  for (int i = 0; i < h; i++) {
  }

  vector<int> gh(h + 1, 0);
  vector<int> gw(w + 1, 0);
  for (int i = 0; i < n; i++) {
    gh[r(y[i], z[i] * -1)]++;
    gh[r(y[i], z[i])]--;
  }
  for (int i = 0; i < n; i++) {
    gw[r(x[i], z[i] * -1)]++;
    gw[r(x[i], z[i])]--;
  }

  for (int i = 0; i < h; i++)
    gh[i + 1] += gh[i];
  for (int i = 0; i < w; i++)
    gw[i + 1] += gw[i];

  bool f1 = true, f2 = true;
  for (int i = 0; i < h; i++)
    if (gh[i] == 0)
      f1 = false;
  for (int i = 0; i < w; i++)
    if (gw[i] == 0)
      f2 = false;
  if (f1 || f2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
Problem p01712 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <map>
#include <utility>
using namespace std;

class S {
public:
  S(int length) : length(length) {
    part.insert(make_pair(length + 1, length + 1));
  }
  void add_ap(int pos, int power) {
    int start = max(pos - power, 0), end = min(pos + power, length);
    auto it = part.lower_bound(start);
    if (it != part.begin())
      it--;
    while (true) {
      if (end < it->first) { // (A)(B)
        part.insert(make_pair(start, end));
        break;
      } else if (start < it->first) {
        if (end <= it->second) { // (A()B)
          part.insert(make_pair(start, it->second));
          part.erase(it);
          break;
        } else { // (A(B)...
          part.erase(it++);
        }
      } else if (start <= it->second) {
        if (end <= it->second) { // (B(A))
          break;
        } else { // (B()A...
          start = it->first;
          part.erase(it++);
        }
      } else { // (B)(A...
        it++;
      }
    }
  }
  bool covered() {
    auto f = part.begin();
    return f != part.end() & f->first == 0 & f->second == length;
  }

private:
  int length;
  map<int, int> part;
};

int main() {
  int n, w, h;
  cin >> n >> w >> h;
  S xs = S(w), ys = S(h);
  bool covered = false;
  int x, y, p;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> p;
    xs.add_ap(x, p);
    ys.add_ap(y, p);
    if (xs.covered() | ys.covered()) {
      covered = true;
      break;
    }
  }
  cout << (covered ? "Yes" : "No") << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <utility>
using namespace std;

class S {
public:
  S(int length) : length(length) {
    part.insert(make_pair(length + 1, length + 1));
  }
  void add_ap(int pos, int power) {
    int start = max(pos - power, 0), end = min(pos + power, length);
    auto it = part.lower_bound(start);
    if (it != part.begin())
      it++;
    while (true) {
      if (end < it->first) { // (A)(B)
        part.insert(make_pair(start, end));
        break;
      } else if (start < it->first) {
        if (end <= it->second) { // (A()B)
          part.insert(make_pair(start, it->second));
          part.erase(it);
          break;
        } else { // (A(B)...
          part.erase(it++);
        }
      } else if (start <= it->second) {
        if (end <= it->second) { // (B(A))
          break;
        } else { // (B()A...
          start = it->first;
          part.erase(it++);
        }
      } else { // (B)(A...
        it++;
      }
    }
  }
  bool covered() {
    auto f = part.begin();
    return f != part.end() & f->first == 0 & f->second == length;
  }

private:
  int length;
  map<int, int> part;
};

int main() {
  int n, w, h;
  cin >> n >> w >> h;
  S xs = S(w), ys = S(h);
  bool covered = false;
  int x, y, p;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> p;
    xs.add_ap(x, p);
    ys.add_ap(y, p);
    if (xs.covered() | ys.covered()) {
      covered = true;
      break;
    }
  }
  cout << (covered ? "Yes" : "No") << endl;
  return 0;
}
Problem p01712 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int smallx[100000], bigx[100000], smally[100000], bigy[100000];
int main() {
  int n, h, w, x, y, z;
  cin >> n >> w >> h;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> z;
    smallx[i] = x - z, bigx[i] = x + z;
    smally[i] = y - z, bigy[i] = y + z;
  }
  sort(smallx, smallx + n), sort(bigx, bigx + n);
  sort(smally, smally + n), sort(bigy, bigy + n);
  bool tx = true, ty = true;
  for (int i = 1; i < n; i++) {
    if (smallx[i] > bigx[i - 1])
      tx = false;
    if (smally[i] > bigy[i - 1])
      ty = false;
  }
  if (smallx[0] > 0 || bigx[n - 1] < w)
    tx = false;
  if (smally[0] > 0 || bigy[n - 1] < h)
    ty = false;
  if (tx == true || ty == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
bool hh[100000], ww[100000];
int main() {
  int n, h, w, x, y, z;
  cin >> n >> h >> w;
  for (int i = 0; i < h; i++)
    hh[i] = false;
  for (int i = 0; i < w; i++)
    ww[i] = false;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> z;
    for (int j = max(x - z, 0); j < min(x + z, h); j++)
      hh[j] = true;
    for (int j = max(y - z, 0); j < min(y + z, w); j++)
      ww[j] = true;
  }
  bool t = false, f = true;
  for (int i = 0; i < h; i++) {
    if (hh[i] == false) {
      f = false;
    }
  }
  if (f == true)
    t = true;
  f = true;
  for (int i = 0; i < w; i++) {
    if (ww[i] == false) {
      f = false;
    }
  }
  if (f == true)
    t = true;
  if (t == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p01712 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
int main() {

  int n, w, h, x, y, haba, i;
  pair<int, int> x1[100000], y1[100000];

  cin >> n >> w >> h;

  for (i = 0; i < n; i++) {

    cin >> x >> y >> haba;
    int a, b, c, d;
    a = x - haba;
    b = x + haba;
    c = y - haba;
    d = y + haba;
    if (a < 0)
      a = 0;
    if (b > w)
      b = w;
    if (c < 0)
      c = 0;
    if (d > h)
      d = h;
    x1[i] = make_pair(a, b);
    y1[i] = make_pair(c, d);
  }
  sort(x1, x1 + n);
  sort(y1, y1 + n);
  int wa = 0, ha = 0;
  int maxza = 0;
  if (x1[0].first != 0)
    wa++;
  else {
    for (i = 1; i < n; i++) {
      if (x1[i - 1].first != x1[i].first) {
        maxza = max(x1[i - 1].second, maxza);
        if (maxza < x1[i].first) {
          wa++;
          break;
        }
      }
    }
    if (max(maxza, x1[n - 1].second) < w)
      wa++;
  }
  maxza = 0;
  if (y1[0].first != 0)
    ha++;
  else {
    for (i = 1; i < n; i++) {
      if (y1[i - 1].first != y1[i].first) {
        maxza = max(y1[i - 1].second, maxza);
        if (maxza < y1[i].first) {
          ha++;
          break;
        }
      }
    }
    if (max(maxza, y1[n - 1].second) < h)
      ha++;
  }

  if (wa == 0 || ha == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {

  int n, w, h, x, y, haba, w1[200000] = {0}, h1[200000] = {0}, i;

  cin >> n >> w >> h;

  for (i = 0; i < n; i++) {

    cin >> x >> y >> haba;

    for (int j = x - haba; j <= x + haba - 1; j++)
      if (0 <= j && j < w)
        w1[j] = 1;
    for (int j = y - haba; j <= y + haba - 1; j++)
      if (0 <= j && j < h)
        h1[j] = 1;
  }
  int wa = 0, ha = 0;
  for (i = 0; i < w; i++)
    if (w1[i] == 0)
      wa++;
  for (i = 0; i < h; i++)
    if (h1[i] == 0)
      ha++;

  if (wa == 0 || ha == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}
Problem p01712 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define INF 100000
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long int ll;

const ll MAX = 1000000;

int main() {
  int n, w, h;
  cin >> n >> w >> h;
  vector<pair<int, int>> tate(n);
  vector<pair<int, int>> yoko(n);
  for (int i = 0; i < n; i++) {
    int x, y, ww;
    cin >> x >> y >> ww;
    tate[i] = {y - ww, y + ww};
    yoko[i] = {x - ww, x + ww};
  }
  sort(tate.begin(), tate.end());
  int b = tate[0].second;
  bool ch = true;
  if (tate[0].first <= 0) {
    for (int i = 1; i < n; i++) {
      if (tate[i].first > b) {
        ch = false;
      }
      b = max(b, tate[i].second);
    }
    if (b < h) {
      ch = false;
    }
    if (ch) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  sort(yoko.begin(), yoko.end());
  b = yoko[0].second;
  ch = true;
  if (yoko[0].first <= 0) {
    for (int i = 1; i < n; i++) {
      if (yoko[i].first > b) {
        ch = false;
      }
      b = max(b, yoko[i].second);
    }
    if (b < w) {
      ch = false;
    }
    if (ch) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
    cout << "No" << endl;
  }
}

Error: TLE

Fixed submission:


#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define INF 100000
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long int ll;

const ll MAX = 1000000;

int main() {
  int n, w, h;
  cin >> n >> w >> h;
  vector<int> tate(h, 0);
  vector<int> yoko(w, 0);
  int t = 0, yo = 0;
  for (int i = 0; i < n; i++) {
    int x, y, ww;
    cin >> x >> y >> ww;
    if (t < h and yo < w) {
      for (int i = max(0, y - ww); i < min(h, y + ww); i++) {
        if (tate[i] == 0) {
          tate[i] = 1;
          t++;
        }
      }
    }
    if (yo < w and t < h) {
      for (int i = max(0, x - ww); i < min(x + ww, w); i++) {
        if (yoko[i] == 0) {
          yoko[i] = 1;
          yo++;
        }
      }
    }
  }
  if (t >= h or yo >= w) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
Problem p01712 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define REP(i, n) for (i = 0; i < n; i++)
#define REP1(i, n) for (i = 1; i < n; i++)
#define IREP(i, n) for (i = n - 1; i >= 0; i--)
#define ALL(c) (c).begin(), (c).end()
#define X first
#define Y second;
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, W, H, i, ix, iy, iw;
  cin >> N >> W >> H;
  W++;
  H++;
  int coverX[W];
  int coverY[H];
  memset(coverX, 0, sizeof(coverX));
  memset(coverY, 0, sizeof(coverY));
  // REP(ix,W) cout << coverX[ix] << endl;
  REP(i, N) {
    int x, y, w;
    cin >> x >> y >> w;
    coverX[max(0, x - w)]++;
    coverX[min(W - 1, x + w)]--;
    coverY[max(0, y - w)]++;
    coverY[min(H - 1, y + w)]--;
  }
  int thickness = 0;
  bool coverAllX = true;
  REP(ix, W - 1) {
    thickness += coverX[ix];
    if (!thickness) {
      coverAllX = false;
      break;
    }
  }
  thickness = 0;
  bool coverAllY = true;
  REP(iy, H - 1) {
    thickness += coverY[iy];
    if (!thickness) {
      coverAllY = false;
      break;
    }
  }
  if (coverAllX || coverAllY)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define REP(i, n) for (i = 0; i < n; i++)
#define REP1(i, n) for (i = 1; i < n; i++)
#define IREP(i, n) for (i = n - 1; i >= 0; i--)
#define ALL(c) (c).begin(), (c).end()
#define X first
#define Y second;
using namespace std;

int main() {
  int N, W, H, i, ix, iy, iw;
  cin >> N >> W >> H;
  bool enableX[W];
  bool enableY[H];
  memset(enableX, false, W);
  memset(enableY, false, H);
  REP(i, N) {
    int x, y, w;
    cin >> x >> y >> w;
    for (iw = -w; iw < w; iw++) {
      int xx = x + iw;
      if (0 <= xx && xx < W)
        enableX[xx] = true;
      int yy = y + iw;
      if (0 <= yy && yy < H)
        enableY[yy] = true;
    }
  }
  bool coverAllX = true;
  REP(ix, W) coverAllX &= enableX[ix];
  bool coverAllY = true;
  REP(iy, H) coverAllY &= enableY[iy];
  if (coverAllX || coverAllY)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
Problem p01712 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dx[] = {1, -1, 0, 0, 1, -1, -1, 1};
int miti[300000];
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define mp make_pair
#define fi first
#define sc second

int main() {
  int n, w, h;
  cin >> n >> w >> h;
  int wifi[n][3];
  REP(i, n) { cin >> wifi[i][0] >> wifi[i][1] >> wifi[i][2]; }
  // x軸を調べる
  REP(i, 10020) miti[i] = 0;

  REP(i, n) {
    int a = wifi[i][0];
    int b = wifi[i][2];
    int minx = max(0, a - b);
    int maxx = a + b;

    miti[minx]++;
    miti[maxx]--;
  }
  int total = 0;
  bool flag = true;
  REP(i, w) {
    total += miti[i];
    // cout << miti[i] << i <<endl;
    if (total <= 0) {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
    return 0;
  }

  REP(i, 10020) miti[i] = 0;

  REP(i, n) {
    int a = wifi[i][1];
    int b = wifi[i][2];
    int miny = max(0, a - b);
    int maxy = a + b;

    miti[miny]++;
    miti[maxy]--;
  }
  total = 0;
  flag = true;
  REP(i, h) {
    total += miti[i];
    // cout << miti[i] <<' ' <<i<<endl;
    if (total <= 0) {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dx[] = {1, -1, 0, 0, 1, -1, -1, 1};
int miti[10020];
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n)-1; i >= 0; i--)
#define mp make_pair
#define fi first
#define sc second

int main() {
  int n, w, h;
  cin >> n >> w >> h;
  int wifi[n][3];
  REP(i, n) { cin >> wifi[i][0] >> wifi[i][1] >> wifi[i][2]; }
  // x軸を調べる
  REP(i, 10020) miti[i] = 0;

  REP(i, n) {
    int a = wifi[i][0];
    int b = wifi[i][2];
    int minx = max(0, a - b);
    int maxx = a + b;

    miti[minx]++;
    miti[maxx]--;
  }
  int total = 0;
  bool flag = true;
  REP(i, w) {
    total += miti[i];
    // cout << miti[i] << i <<endl;
    if (total <= 0) {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
    return 0;
  }

  REP(i, 10020) miti[i] = 0;

  REP(i, n) {
    int a = wifi[i][1];
    int b = wifi[i][2];
    int miny = max(0, a - b);
    int maxy = a + b;

    miti[miny]++;
    miti[maxy]--;
  }
  total = 0;
  flag = true;
  REP(i, h) {
    total += miti[i];
    // cout << miti[i] <<' ' <<i<<endl;
    if (total <= 0) {
      flag = false;
      break;
    }
  }
  if (flag) {
    cout << "Yes" << endl;
    return 0;
  }

  cout << "No" << endl;

  return 0;
}