Problem:
問題 A : Koto Distance
問題文
Koto は言わずと知れた碁盤の目の街である．
	この街は東西方向に
W
メートル，南北方向に
H
メートルに伸びる長方形の領域によってできている．
	この街の西端から
x
メートル，南端から
y
メートルの点は
(x,  y)
と記される．
	ここの街に住む人は古くから伝わる独自の文化を重んじており，その一つにKoto距離という変わった距離尺度がある．
2つの点
(x_1, y_1)
，
(x_2, y_2)
の Koto 距離は，min
(|x_1 - x_2|,  |y_1 - y_2|)
によって定義される．
最近この街全体に Wifi を使えるようにする計画が立ち上がった．
	現在の計画では，親機を
N
個作ることになっている．
i
番目の親機は点
(x_i,  y_i)
に設置され，Koto距離が
w_i
以下の領域に対して Wifi を提供する．
親機を計画どおり建てた場合に，街の内部及び境界上に Wifi を提供できるかどうかを判定せよ．
なお，Koto距離は一般に三角不等式を満たさないため，距離の公理を満たさないということはここだけの秘密である．
入力形式
入力は以下の形式で与えられる．
N
W
H
x_1
y_1
w_1
...
x_N
y_N
w_N
出力形式
街の内部および境界上に Wifi を提供できるなら “Yes” を，そうでない場合は “No” を出力せよ．
制約
1 ≤ N ≤ 10^5
1 ≤ W ≤ 10^5
1 ≤ H ≤ 10^5
0 ≤ x_i ≤ W
0 ≤ y_i ≤ H
1 ≤ w_i ≤ 10^5
同一座標に親機は複数存在しない
入出力例
入力例 1
3 9 9
2 2 2
5 5 2
8 8 2
出力例 1
Yes
２番目の親機が提供するWifiの範囲は以下の通りである．
入力例 2
2 7 7
2 2 1
6 6 1
出力例 2
No
入力例 3
3 10 20
5 10 5
2 10 1
8 10 1
出力例 3
Yes

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using a2 = array<ll, 2>;
using a3 = array<ll, 3>;

bool chmin(auto& a, const auto& b) { return a > b ? a = b, 1 : 0; }
bool chmax(auto& a, const auto& b) { return a < b ? a = b, 1 : 0; }

ll mod = 998244353;
const ll INF = 1e18;

ifstream in;
ofstream out;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    if(argc > 2) {
        in.open(argv[1]);
        cin.rdbuf(in.rdbuf());
        out.open(argv[2]);
        cout.rdbuf(out.rdbuf());
    }

    ll n, w, h;
    cin >> n >> w >> h;
    vector<ll> wsum(2 * (w + 1), 0), hsum(2 * (h + 1), 0);

    for(int i = 0; i < n; i++) {
        ll x, y, wid;
        cin >> x >> y >> wid;
        wsum[max(0LL, (x - wid) * 2)]++;
        wsum[min((ll)wsum.size() - 1, (x + wid) * 2 + 1)]--;

        hsum[max(0LL, (y - wid) * 2)]++;
        hsum[min((ll)hsum.size() - 1, (y + wid) * 2 + 1)]--;
    }

    bool dou = false, ok;

    ok = true;
    for(int i = 0; i < wsum.size() - 1; i++) {
        wsum[i + 1] += wsum[i];
        ok &= wsum[i] > 0;
    }
    dou |= ok;

    ok = true;
    for(int i = 0; i < hsum.size() - 1; i++) {
        hsum[i + 1] += hsum[i];
        ok &= hsum[i] > 0;
    }
    dou |= ok;

    cout << (dou ? "Yes" : "No") << endl;

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 6528
final_rank: 5

code_snippet: #include<bits/stdc++.h>
// #include<atcoder/all>
// #include<boost/multiprecision/cpp_int.hpp>

using namespace std;
// using namespace atcoder;
// using bint = boost::multiprecision::cpp_int;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ve = vector<vector<int>>;
using vb = vector<bool>;
using vvb = vector<vb>;
#define rep(i,s,n) for(ll i = (ll)s;i < (ll)n;i++)
#define rrep(i,l,r) for(ll i = r-1;i >= l;i--)
#define ALL(x) (x).begin(),(x).end()
#define sz(c) ((ll)(c).size())
#define LB(A,x) (int)(lower_bound(A.begin(),A.end(),x)-A.begin())
#define UB(A,x) (int)(upper_bound(A.begin(),A.end(),x)-A.begin())
// #define MOD 1000000007
#define MOD 998244353
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<typename T>ostream&operator<<(ostream&os,vector<T>&v){for(int i = 0;i < v.size();i++)os<<v[i]<<(i+1!=v.size()?" ":"");return os;}
template<typename T>istream&operator>>(istream&is,vector<T>&v){for(T&in:v)is>>in;return is;}
template<typename T1,typename T2>ostream&operator<<(ostream&os,pair<T1,T2>&p){os<<p.first<<" "<<p.second;return os;}
template<typename T1,typename T2>istream&operator>>(istream&is,pair<T1,T2>&p){is>>p.first>>p.second;return is;}
template<typename T> inline bool chmax(T &a,T b){if(a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a,T b){if(a > b){a = b;return true;}return false;}
ld dist(ld x1,ld y1,ld x2, ld y2){return sqrtl((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}


int main(){
  
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n,w,h;cin >> n >> w >> h;
  const int MX = 500000;
  vi X(1000000),Y(1000000);
  rep(i,0,n){
    int x,y,L;cin >> x >> y >> L;
    X[MX+x-L]++;X[MX+x+L]--;
    Y[MX+y-L]++;Y[MX+y+L]--;
  }
  rep(i,0,1000000-1)X[i+1] += X[i],Y[i+1] += Y[i];
  bool isx = true,isy = true;
  rep(i,MX,MX+w)if(!X[i])isx = false;
  rep(i,MX,MX+h)if(!Y[i])isy = false;
  cout << (isx || isy ? "Yes" : "No") << endl;
  

  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 18828
final_rank: 18

code_snippet: #include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i = s; i < t ; i++)
using LL = long long; using VL = vector<LL>;
template<class T> using V = vector<T>; template<class T> using VV = V<V<T>>;
const LL LINF = 1e18;

void solve() {
	int N, W, H;
	cin >> N >> W >> H;
	// 街の内部及び境界上全部? -> ?
	// 軸は独立 -> imos
	int flag = 0;
	V<int> xs(W + 10, 0), ys(H + 10, 0);
	FOR(i, 0, N) {
		int x, y, w;
		cin >> x >> y >> w;
		xs[max(0, x - w)]++;
		xs[min(W + 5, x + w)]--;
		ys[max(0, y - w)]++;
		ys[min(H + 5, y + w)]--;
	}
	int xinfo = 1;
	FOR(i, 0, W) {
		xs[i + 1] += xs[i];
		if (xs[i] == 0)xinfo = 0;// 適用できなさそう
	}

	int yinfo = 1;
	FOR(i, 0, H) {
		ys[i + 1] += ys[i];
		if (ys[i] == 0)yinfo = 0; // 適用できなさそう
	}
//	cout << xinfo << "," << yinfo << endl;
	if (xinfo || yinfo) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	solve();

	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3876
final_rank: 1

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <ranges>
namespace ranges = std::ranges;
int N, W, H;
int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cin >> N >> W >> H;
    std::vector<int> x(2 * W + 2), y(2 * H + 2);
    for (int i = 0 ; i < N ; i++) {
        int X, Y, D;
        std::cin >> X >> Y >> D;
        X *= 2;
        Y *= 2;
        D *= 2;
        x[std::max(0, X - D)]++;
        y[std::max(0, Y - D)]++;
        x[std::min(2*W+1, X + D + 1)]--;
        y[std::min(2*H+1, Y + D + 1)]--;
    }
    for (int i = 1 ; i < std::ssize(x) ; i++) x[i] += x[i - 1];
    for (int i = 1 ; i < std::ssize(y) ; i++) y[i] += y[i - 1];
    x.pop_back();
    y.pop_back();
    const int ans =  
        ranges::all_of(x, [&](int v) { return v > 0; })
        or
        ranges::all_of(y, [&](int v) { return v > 0; });
    std::cout << (ans ? "Yes\n" : "No\n");
}
accuracy: 1
time_ms: 10
memory_kb: 4992
final_rank: 3

code_snippet: #include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define rep(i, m, n) for (ll i = (ll)m; i < (ll)n; i++)
#define drep(i, m, n) for (ll i = m - 1; i >= n; i--)
#define Endl endl
#define all(a) a.begin(), a.end()
#define pr(i, j) make_pair(i, j)
#define isin(x, l, r) (l <= x && x < r)
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define srt(ar) sort(ar.begin(), ar.end())
#define rev(ar) reverse(ar.begin(), ar.end())
#define jge(f, s, t) cout << (f ? s : t) << endl
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define printar(ar)             \
    do                          \
    {                           \
        for (auto dbg : ar)     \
        {                       \
            cout << dbg << " "; \
        }                       \
        cout << endl;           \
    } while (0)
const ll inf = 1e18;
const ld pi = 3.14159265358979;
const ld eps = 1e-9;
template <class T, ll n, ll idx = 0>
auto make_vec(const ll (&d)[n], const T &init) noexcept
{
    if constexpr (idx < n)
        return std::vector(d[idx], make_vec<T, n, idx + 1>(d, init));
    else
        return init;
}

template <class T, ll n>
auto make_vec(const ll (&d)[n]) noexcept
{
    return make_vec(d, T{});
}
//////////////// 以下を貼る ////////////////
template <class T>
size_t HashCombine(const size_t seed, const T &v)
{
    return seed ^ (std::hash<T>()(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2));
}
/* pair用 */
template <class T, class S>
struct std::hash<std::pair<T, S>>
{
    size_t operator()(const std::pair<T, S> &keyval) const noexcept
    {
        return HashCombine(std::hash<T>()(keyval.first), keyval.second);
    }
};
////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, W, H;
    cin >> n >> W >> H;
    vector<ll> X(W + 1), Y(H + 1);
    rep(i, 0, n)
    {
        ll x, y, w;
        cin >> x >> y >> w;
        ll a = inf, b = -inf, c = inf, d = -inf;
        chmin(a, max(x - w, 0LL));
        chmax(b, min(x + w, W));
        chmin(c, max(y - w, 0LL));
        chmax(d, min(y + w, W));
        X[a]++;
        X[b]--;
        Y[c]++;
        Y[d]--;
    }
    rep(i, 0, W)
    {
        X[i + 1] += X[i];
    }
    rep(i, 0, H)
    {
        Y[i + 1] += Y[i];
    }
    bool f = true;
    bool g = true;
    rep(i, 0, W)
    {
        if (X[i] == 0)
        {
            f = false;
        }
    }
    /*
    printar(X);
    printar(Y);
    */
    rep(i, 0, H)
    {
        if (Y[i] == 0)
        {
            g = false;
        }
    }
    jge(f || g, "Yes", "No");
}
accuracy: 1
time_ms: 10
memory_kb: 4992
final_rank: 3

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define SZ(v) (int)v.size()
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))
#define LB(v, x) int(lower_bound(ALL(v), (x)) - (v).begin())
#define UB(v, x) int(upper_bound(ALL(v), (x)) - (v).begin())

using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;

template <typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T, typename U> T ceil(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U> T floor(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T> int popcnt(T x) {
    return __builtin_popcountll(x);
}
template <typename T> int topbit(T x) {
    return (x == 0 ? -1 : 63 - __builtin_clzll(x));
}
template <typename T> int lowbit(T x) {
    return (x == 0 ? -1 : __builtin_ctzll(x));
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "P(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#ifdef LOCAL
#define show(...) _show(0, #__VA_ARGS__, __VA_ARGS__)
#else
#define show(...) true
#endif
template <typename T> void _show(int i, T name) {
    cerr << '\n';
}
template <typename T1, typename T2, typename... T3>
void _show(int i, const T1 &a, const T2 &b, const T3 &...c) {
    for (; a[i] != ',' && a[i] != '\0'; i++)
        cerr << a[i];
    cerr << ":" << b << " ";
    _show(i + 1, a, c...);
}

#include <unistd.h>

namespace fastio {
static constexpr uint32_t SZ = 1 << 17;
char ibuf[SZ];
char obuf[SZ];
char out[100];
// pointer of ibuf, obuf


uint32_t pil = 0, pir = 0, por = 0;

struct Pre {
    char num[10000][4];
    constexpr Pre() : num() {
        for (int i = 0; i < 10000; i++) {
            int n = i;
            for (int j = 3; j >= 0; j--) {
                num[i][j] = n % 10 | '0';
                n /= 10;
            }
        }
    }
} constexpr pre;

inline void load() {
    memmove(ibuf, ibuf + pil, pir - pil);
    pir = pir - pil + fread(ibuf + pir - pil, 1, SZ - pir + pil, stdin);
    pil = 0;
    if (pir < SZ)
        ibuf[pir++] = '\n';
}

inline void flush() {
    fwrite(obuf, 1, por, stdout);
    por = 0;
}

void rd(char &c) {
    do {
        if (pil + 1 > pir)
            load();
        c = ibuf[pil++];
    } while (isspace(c));
}

void rd(string &x) {
    x.clear();
    char c;
    do {
        if (pil + 1 > pir)
            load();
        c = ibuf[pil++];
    } while (isspace(c));
    do {
        x += c;
        if (pil == pir)
            load();
        c = ibuf[pil++];
    } while (!isspace(c));
}

template <typename T> void rd_real(T &x) {
    string s;
    rd(s);
    x = stod(s);
}

template <typename T> void rd_integer(T &x) {
    if (pil + 100 > pir)
        load();
    char c;
    do
        c = ibuf[pil++];
    while (c < '-');
    bool minus = 0;
    if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
        if (c == '-') {
            minus = 1, c = ibuf[pil++];
        }
    }
    x = 0;
    while ('0' <= c) {
        x = x * 10 + (c & 15), c = ibuf[pil++];
    }
    if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
        if (minus)
            x = -x;
    }
}

void rd(int &x) {
    rd_integer(x);
}
void rd(ll &x) {
    rd_integer(x);
}
void rd(i128 &x) {
    rd_integer(x);
}
void rd(uint &x) {
    rd_integer(x);
}
void rd(ull &x) {
    rd_integer(x);
}
void rd(u128 &x) {
    rd_integer(x);
}
void rd(double &x) {
    rd_real(x);
}
void rd(long double &x) {
    rd_real(x);
}

template <class T, class U> void rd(pair<T, U> &p) {
    return rd(p.first), rd(p.second);
}
template <size_t N = 0, typename T> void rd_tuple(T &t) {
    if constexpr (N < std::tuple_size<T>::value) {
        auto &x = std::get<N>(t);
        rd(x);
        rd_tuple<N + 1>(t);
    }
}
template <class... T> void rd(tuple<T...> &tpl) {
    rd_tuple(tpl);
}

template <size_t N = 0, typename T> void rd(array<T, N> &x) {
    for (auto &d : x)
        rd(d);
}
template <class T> void rd(vector<T> &x) {
    for (auto &d : x)
        rd(d);
}

void read() {}
template <class H, class... T> void read(H &h, T &...t) {
    rd(h), read(t...);
}

void wt(const char c) {
    if (por == SZ)
        flush();
    obuf[por++] = c;
}
void wt(const string s) {
    for (char c : s)
        wt(c);
}
void wt(const char *s) {
    size_t len = strlen(s);
    for (size_t i = 0; i < len; i++)
        wt(s[i]);
}

template <typename T> void wt_integer(T x) {
    if (por > SZ - 100)
        flush();
    if (x < 0) {
        obuf[por++] = '-', x = -x;
    }
    int outi;
    for (outi = 96; x >= 10000; outi -= 4) {
        memcpy(out + outi, pre.num[x % 10000], 4);
        x /= 10000;
    }
    if (x >= 1000) {
        memcpy(obuf + por, pre.num[x], 4);
        por += 4;
    } else if (x >= 100) {
        memcpy(obuf + por, pre.num[x] + 1, 3);
        por += 3;
    } else if (x >= 10) {
        int q = (x * 103) >> 10;
        obuf[por] = q | '0';
        obuf[por + 1] = (x - q * 10) | '0';
        por += 2;
    } else
        obuf[por++] = x | '0';
    memcpy(obuf + por, out + outi + 4, 96 - outi);
    por += 96 - outi;
}

template <typename T> void wt_real(T x) {
    ostringstream oss;
    oss << fixed << setprecision(15) << double(x);
    string s = oss.str();
    wt(s);
}

void wt(int x) {
    wt_integer(x);
}
void wt(ll x) {
    wt_integer(x);
}
void wt(i128 x) {
    wt_integer(x);
}
void wt(uint x) {
    wt_integer(x);
}
void wt(ull x) {
    wt_integer(x);
}
void wt(u128 x) {
    wt_integer(x);
}
void wt(double x) {
    wt_real(x);
}
void wt(long double x) {
    wt_real(x);
}

template <class T, class U> void wt(const pair<T, U> val) {
    wt(val.first);
    wt(' ');
    wt(val.second);
}
template <size_t N = 0, typename T> void wt_tuple(const T t) {
    if constexpr (N < std::tuple_size<T>::value) {
        if constexpr (N > 0) {
            wt(' ');
        }
        const auto x = std::get<N>(t);
        wt(x);
        wt_tuple<N + 1>(t);
    }
}
template <class... T> void wt(tuple<T...> tpl) {
    wt_tuple(tpl);
}
template <class T, size_t S> void wt(const array<T, S> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
        if (i)
            wt(' ');
        wt(val[i]);
    }
}
template <class T> void wt(const vector<T> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
        if (i)
            wt(' ');
        wt(val[i]);
    }
}

void print() {
    wt('\n');
}
template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
    wt(head);
    if (sizeof...(Tail))
        wt(' ');
    print(forward<Tail>(tail)...);
}
void __attribute__((destructor)) _d() {
    flush();
}
} // namespace fastio


using fastio::flush;
using fastio::print;
using fastio::read;

inline void first(bool i = true) {
    print(i ? "first" : "second");
}
inline void Alice(bool i = true) {
    print(i ? "Alice" : "Bob");
}
inline void Takahashi(bool i = true) {
    print(i ? "Takahashi" : "Aoki");
}
inline void yes(bool i = true) {
    print(i ? "yes" : "no");
}
inline void Yes(bool i = true) {
    print(i ? "Yes" : "No");
}
inline void No() {
    print("No");
}
inline void YES(bool i = true) {
    print(i ? "YES" : "NO");
}
inline void NO() {
    print("NO");
}
inline void Yay(bool i = true) {
    print(i ? "Yay!" : ":(");
}
inline void Possible(bool i = true) {
    print(i ? "Possible" : "Impossible");
}
inline void POSSIBLE(bool i = true) {
    print(i ? "POSSIBLE" : "IMPOSSIBLE");
}

/**
 * @brief Fast IO
 */

int main() {
    int Q, N, M;
    cin >> Q >> N >> M;
    vector<int> A(N+1,0), B(M+1,0);
    rep(i,0,Q) {
        int X, Y, Z;
        cin >> X >> Y >> Z;
        A[max(0,X-Z)]++, A[min(N,X+Z)]--;
        B[max(0,Y-Z)]++, B[min(N,Y+Z)]--;
    }
    rep(i,0,N) A[i+1] += A[i];
    rep(i,0,M) B[i+1] += B[i];
    bool check1 = true, check2 = true;
    rep(i,0,N) if (A[i]==0) check1 = false;
    rep(i,0,M) if (B[i]==0) check2 = false;
    if (check1 || check2) cout << "Yes" << endl;
    else cout << "No" << endl;
}
accuracy: 1
time_ms: 40
memory_kb: 3956
final_rank: 9

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
#define rep(i, n) for(int i=0;i<n;i++)
#define foa(e, v) for(auto&& e : v)
using ll = long long;
const ll MOD7 = 1000000007, MOD998 = 998244353, INF = (1LL << 60);
#define dout(a) cout<<fixed<<setprecision(10)<<a<<endl;

bool solve(vector<pair<ll, ll>> v, ll w) {
    vector<ll> cnt(w + 1, 0);
    for(auto [x, d] : v) {
        ll num1 = max(0LL, x - d);
        ll num2 = min(w, x + d);
        cnt[num1] ++;
        cnt[num2] --;
    }
    rep(i, w) cnt[i + 1] += cnt[i];
    rep(i, w) if(!cnt[i]) return 0;
    return 1;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, h, w;
    cin >> n >> w >> h;
    vector<pair<ll, ll>> v1, v2;
    rep(i, n) {
        ll a, b, d;
        cin >> a >> b >> d;
        v1.push_back({a, d});
        v2.push_back({b, d});
    }
    cout << (solve(v1, w) or solve(v2, h) ? "Yes" : "No") << endl;
    
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 10212
final_rank: 13

code_snippet: // (⁠◕⁠ᴗ⁠◕⁠✿⁠)

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define srep(i, s, n) for (ll i = s; i < (n); i++)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
template<typename T> using vc = vector<T>;
template<typename T> using vv = vc<vc<T>>;
template<typename T> using vvv = vv<vc<T>>;
using vi = vc<int>;using vvi = vv<int>; using vvvi = vv<vi>;
using ll = long long;using vl = vc<ll>;using vvl = vv<ll>; using vvvl = vv<vl>;
using ld = long double; using vld = vc<ld>; using vvld = vc<vld>; using vvvld = vc<vvld>;
using uint = unsigned int;
using ull = unsigned long long;
const ld pi = 3.141592653589793;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
// const ll mod = 1000000007;
const ll mod = 998244353;
inline bool inside(ll y, ll x, ll H, ll W) {return 0 <= (y) and (y) < (H) and 0 <= (x) and (x) < (W); }

#define debug(var)  do{std::cout << #var << " : \n";view(var);}while(0)
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vc<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vv<T>& vv){ for(const auto& v : vv){ view(v); } }

int main(){
    int N, H, W; cin >> N >> H >> W;
    vi nh(H + 1, 0), nw(W + 1, 0);
    rep(i, N){
        int x, y, w; cin >> x >> y >> w;
        nh[max(0, x - w)]++;
        nh[min(H, x + w)]--;
        nw[max(0, y - w)]++;
        nw[min(W, y + w)]--;
    }
    rep(i, H) nh[i + 1] += nh[i];
    rep(i, W) nw[i + 1] += nw[i];
    bool f = true, g = true;
    rep(i, H) if (!nh[i]) f = false;
    rep(i, W) if (!nw[i]) g = false;
    if (f | g) cout << "Yes" << endl;
    else cout << "No" << endl;
}
accuracy: 1
time_ms: 40
memory_kb: 3884
final_rank: 6

code_snippet: #include <bits/stdc++.h>

int main() {
    int n, h, w;
    std::cin >> n >> h >> w;
    std::vector<int> x(h + 1), y(w + 1);
    for (int i = 0; i < n; i++) {
        int a, b, c;
        std::cin >> a >> b >> c;
        {
            int l = std::max(0, a - c);
            int r = std::min(h, a + c);
            x[l]++;
            x[r]--;
        }
        {
            int l = std::max(0, b - c);
            int r = std::min(w, b + c);
            y[l]++;
            y[r]--;
        }
    }
    for (int i = 0; i < h; i++) x[i + 1] += x[i];
    for (int i = 0; i < w; i++) y[i + 1] += y[i];
    bool ok_x = true;
    bool ok_y = true;
    for (int i = 0; i < h; i++) ok_x &= x[i] > 0;
    for (int i = 0; i < w; i++) ok_y &= y[i] > 0;
    std::cout << (ok_x || ok_y ? "Yes" : "No") << '\n';
}
accuracy: 1
time_ms: 40
memory_kb: 3896
final_rank: 8

code_snippet: #include<bits/stdc++.h>
using namespace std;
int main(){
    int n, w, h, x, y, z;
    int tl=0, tate[100005]={};
    int yl=0, yoko[100005]={};
    cin >> n >> w >> h;
    for(int i=0;i<n;i++){
        cin >> x >> y >> z;
        tate[max(0, x-z)]++;
        if(x+z<w) tate[x+z]--;
        yoko[max(0, y-z)]++;
        if(y+z<h) yoko[y+z]--;
    }
    for(int i=1;i<=w;i++) tate[i] += tate[i-1];
    for(int j=1;j<=h;j++) yoko[j] += yoko[j-1];
    int cnt=0;
    for(int i=0;i<=w;i++){
        if(tate[i]==0 && cnt==0) cnt=1;
    }
    for(int i=0;i<=h;i++){
        if(yoko[i]==0 && cnt==1) cnt=2;
    }
    if(cnt == 2) cout << "No" << endl;
    else cout << "Yes" << endl;
    return(0);
}
accuracy: 1
time_ms: 60
memory_kb: 3856
final_rank: 16

code_snippet: #include<bits/stdc++.h>
using namespace std;

int N,W,H,SH[1<<17],SW[1<<17];

int main()
{
    cin>>N>>W>>H;
    for(int i=0; i<N; i++)
    {
        int x,y,w;
        cin>>x>>y>>w;
        SH[min(H,y+w)]--;
        SH[max(0,y-w)]++;
        SW[min(W,x+w)]--;
        SW[max(0,x-w)]++;
    }
    for(int i=1; i<=H; i++)SH[i]+=SH[i-1];
    for(int j=1; j<=W; j++)SW[j]+=SW[j-1];
    bool flag=1;
    for(int i=0; i<H; i++)
    {
        if(SH[i]<=0)flag=0;
        // cout << SH[i] << (i==H?'\n':' ');
    }
    if(flag)
    {
        cout << "Yes\n";
        return 0;
    }
    flag=1;
    for(int j=0; j<W; j++)
    {
        if(SW[j]<=0)flag=0;
        // cout << SW[j] << (j==W?'\n':' ');
    }
    cout << (flag?"Yes\n":"No\n");
}
accuracy: 1
time_ms: 40
memory_kb: 4200
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;

int main() {
	int N, H, W;
	cin >> N >> H >> W;
	vector<int> imos_row(H+1), imos_col(W+1);
	for( int i = 0; i < N; i++ ) {
		int x, y, w;
		cin >> x >> y >> w;
		imos_row[max(0, x-w)]++;
		imos_row[min(H, x+w)]--;
		imos_col[max(0, y-w)]++;
		imos_col[min(W, y+w)]--;
	}
	bool ok_row = true, ok_col = true;
	for( int i = 0; i < H; i++ ) {
		if( imos_row[i] <= 0 ) ok_row = false;
		imos_row[i+1] += imos_row[i];
	}
	for( int i = 0; i < W; i++ ) {
		if( imos_col[i] <= 0 ) ok_col = false;
		imos_col[i+1] += imos_col[i];
	}
	cout << ( ok_row || ok_col ? "Yes" : "No" ) << endl;
}
accuracy: 1
time_ms: 40
memory_kb: 3884
final_rank: 6

code_snippet: #include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const int INF = 1001001001;
using P = pair<int, int>;

int main() {
    int n, w, h; cin >> n >> w >> h;
    vector<pair<int, int>> xs(n), ys(n);
    for (int i = 0; i < n; i++) {
        int x, y, z; cin >> x >> y >> z;
        xs[i] = {x - z, x + z};
        ys[i] = {y - z, y + z};
    }
    auto f = [](P l, P r) {
        if (l.first != r.first) { return l.first < r.first ; }
        return l.second > r.second;
    };
    sort(xs.begin(), xs.end(), f);
    sort(ys.begin(), ys.end(), f);
    bool ok = true;
    int pre = 0;
    for (int i = 0; i < n; i++) {
        auto [l, r] = xs[i];
        if (l <= pre) {
            pre = max(r, pre);
        } else {
            ok = false;
        }
    }
    if (ok and w <= pre)  {
        cout << "Yes" << endl;
        return 0;
    }
    ok = true;
    pre = 0;
    for (int i = 0; i < n; i++) {
        auto [l, r] = ys[i];
        if (l <= pre) {
            pre = max(r, pre);
        } else {
            ok = false;
        }
    }
    if (ok and h <= pre)  {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;

}
accuracy: 1
time_ms: 50
memory_kb: 4704
final_rank: 15

code_snippet: #include <bits/stdc++.h>
using namespace std;

bool solve() {
    int N, W, H;
    cin >> N >> W >> H;
    vector<int> x(N), y(N), w(N);
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i] >> w[i];
    vector<int> tx(W+2), ty(H+2), imosx(W+1), imosy(H+1);
    for (int i = 0; i < N; i++) {
        tx[max(0, x[i] - w[i])]++;
        tx[min(W+1, x[i] + w[i] + 1)]--;
        ty[max(0, y[i] - w[i])]++;
        ty[min(H+1, y[i] + w[i] + 1)]--;
    }
    imosx[0] = tx[0]; imosy[0] = ty[0];
    for (int i = 1; i <= W; i++) imosx[i] = imosx[i - 1] + tx[i];
    for (int i = 1; i <= H; i++) imosy[i] = imosy[i - 1] + ty[i];
    
    bool existx = false, existy = false;
    for (int i = 0; i <= W; i++) {
        if (imosx[i] == 0) existx = true;
    }
    for (int i = 0; i <= H; i++) {
        if (imosy[i] == 0) existy = true;
    }
    for (int i = 0; i < N; i++) {
        if (x[i]+w[i] < W && imosx[x[i] + w[i]] == 1) existx = true;
        if (y[i]+w[i] < H && imosy[y[i] + w[i]] == 1) existy = true;
    }
    cout << (existx && existy? "No" : "Yes") << endl;
    return false;
}

int main() {
    while (solve());
}
accuracy: 1
time_ms: 40
memory_kb: 5796
final_rank: 14

code_snippet: #line 2 "template.hpp"
#include <bits/stdc++.h>
#line 4 "template.hpp"
using namespace std;
#define square(x) ((x)*(x))
#define endl '\n'
#define debug(val); cerr << #val << ": " << val << endl;

// 型エイリアス
using ll = long long int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
using uint = unsigned int;
using T3 = tuple<ll, int, int>;
// 定数
constexpr int INT_INF = 1e9 + 1;
constexpr ll INF = 1LL << 60;
// constexpr ll MOD = (long long)1e9 + 7;
constexpr ll MOD = 998244353;

// 配列での方向
// 上下左右（右から時計回り）
constexpr int dx[4] = { 1, 0, -1, 0 };
constexpr int dy[4] = { 0, 1, 0, -1 };
// 斜め4方向（右上から時計回り）
//constexpr int dx[4] = { 1, 1, -1, -1 };
//constexpr int dy[4] = { -1, 1, 1, -1 };
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void Yes(bool yes)
{
    if (yes) cout << "Yes" << '\n';
    else cout << "No" << '\n';
}

// pii
ostream& operator<<(ostream& os, pii p) {
    return os << '(' << p.first << ',' << p.second << ')';
}
// vector<T>
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    for (const T& val : v)
    {
        os << val << ' ';
    }

    return os;
}
// vector<vector<T>>
template <typename T>
ostream& operator<<(ostream& os, const vector<vector<T>>& v)
{
    for (const vector<T>& line : v)
    {
        os << endl;
        for (const T& val : line)
        {
            os << val << ' ';
        }
    }

    return os;
}
// set<T>
template <typename T>
ostream& operator<<(ostream& os, const set<T>& s)
{
    for (auto itr = s.begin(); itr != s.end(); ++itr)
    {
        os << *itr << ' ';
    }
    return os;
}
#line 3 "DataStructure\\Point.hpp"

/*
* Point<int> p;
* 
Point()     0で初期化
Point(x, y) (x,y)で初期化
operator +  加算
operator -  減算
operator += 
operator -= 
operator == 比較
operator != 
operator <  大小比較
operator >  
operator << 出力(x,y)
operator >> 入力(x,yの順)
Rotate45()  45度回転
ManhattanDistance(Point)    マンハッタン距離
EuclidDistance(Point)    ユークリッド距離
*/
template<class T>
struct Point
{
    T x, y;

    Point()
    {
        this->x = T(0);
        this->y = T(0);
    }
    Point(const T& x, const T& y)
    {
        this->x = x;
        this->y = y;
    }

    Point operator +(const Point& op) const
    {
        return Point(this->x + op.x, this->y + op.y);
    }
    Point operator -(const Point& op) const
    {
        return Point(this->x - op.x, this->y - op.y);
    }
    Point& operator +=(const Point& op)
    {
        this->x += op.x;
        this->y += op.y;
        return *this;
    }
    Point& operator -=(const Point& op)
    {
        this->x -= op.x;
        this->y -= op.y;
        return *this;
    }
    bool operator ==(const Point& op) const
    {
        return this->x == op.x && this->y == op.y;
    }
    bool operator !=(const Point& op) const {
        return !(*this == op);
    }
    bool operator<(const Point& op) const {
        if (x == op.x) return y < op.y;
        else return x < op.x;
    }
    bool operator>(const Point& op) const {
        if (x == op.x) return y > op.y;
        else return x > op.x;
    }

    void Rotate45() {
        x = x + y;
        y = x - 2 * y;
    }
    T ManhattanDistance(const Point& other) {
        return abs(x - other.x) + abs(y - other.y);
    }
    double EuclidDistance(const Point& other) {
        return sqrt(square(x - other.x) + square(y - other.y));
    }
};
template<class T>
ostream& operator <<(ostream& os, const Point<T>& op)
{
    os << '(' << op.x << ',' << op.y << ')';
    return os;
}
template<class T>
istream& operator>>(istream& is, Point<T>& op)
{
    is >> op.x >> op.y;
    return is;
}
using pint = Point<int>;
bool cmp_y(pint a, pint b)
{
    if (a.y == b.y) return a.x < b.x;
    else return a.y < b.y;
}

// 偏角ソート用比較関数
template <class T>
bool compare_angle(Point<T> a, Point<T> b)
{
    double ata = atan2(a.y, a.x);
    double atb = atan2(b.y, b.x);

    if (ata == atb)
    {
        return a.EuclidDistance(0, 0) < b.EuclidDistance(0, 0);
    }
    else
    {
        return ata < atb;
    }
}
#line 3 "a.cpp"

int N, W, H;
vector<pint> p;
map<pint, int> w;

int main(void) {
	cin >> N >> W >> H;
	p.resize(N);
	for (int i = 0; i < N; ++i) {
		int ww;
		cin >> p[i] >> ww;
		w[p[i]] = ww;
	}

	// x
	bool okX = true;
	vector<int> fill(W + 2, 0);
	for (int i = 0; i < N; ++i) {
		int beg = max(0, p[i].x - w[p[i]]);
		int end = min(p[i].x + w[p[i]], W);
		fill[beg] += 1;
		fill[end] -= 1;
	}
	for (int i = 0; i < W; ++i) {
		fill[i + 1] += fill[i];
		if (fill[i] <= 0) {
			okX = false;
		}
	}
	// y
	bool okY = true;
	fill.clear();
	fill.resize(H + 2, 0);
	for (int i = 0; i < N; ++i) {
		int beg = max(0, p[i].y - w[p[i]]);
		int end = min(p[i].y + w[p[i]], H);
		fill[beg] += 1;
		fill[end] -= 1;
	}
	for (int i = 0; i < H; ++i) {
		fill[i + 1] += fill[i];
		if (fill[i] <= 0) {
			okY = false;
		}
	}
	Yes(okX || okY);
}
accuracy: 1
time_ms: 110
memory_kb: 10472
final_rank: 20

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll x[100010],y[100010];
int main(void){
    ll n,w,h,a,b,c,d=0;
    cin>>n>>w>>h;
    for(ll i=0;i<n;i++){
        cin>>a>>b>>c;
        y[max(0LL,b-c)]--;
		y[min(h,b+c)]++;
		x[max(0LL,a-c)]--;
		x[min(w,a+c)]++;
    }
    for(ll i=1;i<=h;i++){
        y[i]+=y[i-1];
    }
    for(ll i=1;i<=w;i++){
        x[i]+=x[i-1];
    }
    for(ll i=0;i<h;i++){
        if(y[i]==0){
            d++;
            break;
        }
    }
    for(ll i=0;i<w;i++){
        if(x[i]==0){
            d++;
            break;
        }
    }
    if(d==2){
        cout<<"No\n";
    }else{
        cout<<"Yes\n";
    }
    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 5012
final_rank: 12

code_snippet: #include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, j, n) for (int i = j; i < (n); ++i)
#define rrep(i, j, n) for (int i = (n)-1; j <= i; --i)
#define all(a) a.begin(), a.end()
template <typename T>
std::ostream &operator<<(std::ostream &os, std::vector<T> &a) {
  for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? " " : "") << a[i];
  return os << '\n';
}
template <typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &a) {
  for (T &x : a) { is >> x; }
  return is;
}

bool in(int x, int y, int limx, int limy) {
  return 0 <= x && x < limx && 0 <= y && y < limy;
}

[[maybe_unused]] static constexpr long long MOD = 998244353;
[[maybe_unused]] static constexpr int INF = 0x3f3f3f3f;
[[maybe_unused]] static constexpr long long INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  int n, W, h;
  cin >> n >> W >> h;
  h *= 2, W *= 2;
  vector<int> sh(h + 2), sw(W + 2);
  rep(i, 0, n) {
    int x, y, w;
    cin >> x >> y >> w;
    x *= 2, y *= 2, w *= 2;
    sh[max(0, y - w)]++;
    sh[min(y + w + 1, h + 1)]--;
    sw[max(0, x - w)]++;
    sw[min(x + w + 1, W + 1)]--;
  }
  rep(i, 0, h + 1) sh[i + 1] += sh[i];
  rep(i, 0, W + 1) sw[i + 1] += sw[i];
  bool xok = true, yok = true;
  rep(i, 0, h + 1) xok &= sh[i] > 0;
  rep(i, 0, W + 1) yok &= sw[i] > 0;
  cout << (xok || yok ? "Yes" : "No") << '\n';
}
accuracy: 1
time_ms: 10
memory_kb: 4676
final_rank: 2

code_snippet: #include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define reps(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define rrep(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (ll)n; i > 0; i--)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
#define all(x) x.begin(), x.end()

template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

ll factorial(ll n)
{
    if (n == 1 || n == 0)
        return 1;
    else
        return n * factorial(n - 1);
}

ll combination(ll a, ll b)
{
    return factorial(a) / (factorial(a - b) * factorial(b));
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

vector<ll> divisors(ll n, bool sorted = false)
{
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            res.push_back(i);
            if (i * i != n)
                res.push_back(n / i);
        }
    }
    if (sorted)
    {
        SORT(res);
    }

    return res;
}

vector<bool> eratosthenes(ll n)
{
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = is_prime[1] = false;

    for (ll p = 2; p <= n; p++)
    {
        if (!is_prime[p])
            continue;
        for (int q = p * 2; q <= n; q += p)
        {
            is_prime[q] = false;
        }
    }

    return is_prime;
}

struct Edge
{
    ll to;
    ll weight;
    Edge(ll to, ll weight) : to(to), weight(weight) {}
};
typedef vector<vector<ll>> Graph;
typedef vector<vector<Edge>> WeightedGraph;

vector<ll> dijkstra(const WeightedGraph &g, ll s)
{
    vector<ll> dis(g.size(), LONG_LONG_MAX);
    dis[s] = 0;
    priority_queue<P, vector<P>, greater<P>> pq;

    pq.push({0, s});
    while (!pq.empty())
    {
        auto [current_dis, v] = pq.top();
        pq.pop();
        if (dis[v] < current_dis)
            continue;
        for (auto e : g[v])
        {
            if (chmin(dis[e.to], current_dis + e.weight))
            {
                pq.push({dis[e.to], e.to});
            }
        }
    }
    return dis;
}

vector<ll> topo_sort(const Graph &g)
{
    vector<ll> res;
    ll n = g.size();
    vector<ll> in_deg(n);

    rep(i, n) for (auto vv : g[i]) in_deg[vv]++;

    queue<ll> que;
    rep(i, n) if (in_deg[i] == 0) que.push(i);

    while (!que.empty())
    {
        ll v = que.front();
        res.push_back(v);
        que.pop();
        for (auto vv : g[v])
        {
            in_deg[vv]--;
            if (in_deg[vv] == 0)
                que.push(vv);
        }
    }

    return res;
}

bool filled(vector<P> sections, ll max)
{
    ll point = 0;
    rep(i, sections.size())
    {
        if (point < sections[i].first)
            return false;
        chmax(point, sections[i].second);
    }
    if (point < max)
        return false;
    return true;
}

int main()
{
    ll n, w, h;
    cin >> n >> w >> h;
    vector<pair<P, ll>> routers;
    rep(i, n)
    {
        ll x, y, w;
        cin >> x >> y >> w;
        routers.push_back({{x, y}, w});
    }

    vector<P> sections_x, sections_y;
    for (auto r : routers)
    {
        ll x = r.first.first;
        ll y = r.first.second;
        ll w = r.second;
        ll x1 = x - w;
        ll x2 = x + w;
        ll y1 = y - w;
        ll y2 = y + w;
        sections_x.push_back({x1, x2});
        sections_y.push_back({y1, y2});
    }
    SORT(sections_x);
    SORT(sections_y);

    if(filled(sections_x, w) || filled(sections_y, h))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 14028
final_rank: 19

code_snippet: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<unordered_set>
#include<set>

using namespace std;

int main(){
    int n,W,H;
    cin>>n>>W>>H;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> w(n);
    vector<int> x_town(W);
    vector<int> y_town(H);
    for(int i=0; i<n; i++){
        cin>>x[i]>>y[i]>>w[i];
        int left_x=max(0,x[i]-w[i]);
        int right_x=min(W,x[i]+w[i]);

        int left_y=max(0,y[i]-w[i]);
        int right_y=min(H,y[i]+w[i]);

        x_town[left_x]++;
        x_town[right_x]--;
        y_town[left_y]++;
        y_town[right_y]--;
    }

    for(int i=1; i<W; i++){
        x_town[i]+=x_town[i-1];
    }

    for(int i=1; i<H; i++){
        y_town[i]+=y_town[i-1];
    }

    bool flg=true;
    bool flg1=true;
    for(int i=0; i<W; i++){
        if(x_town[i]<1) flg=false;
    }

    for(int i=0; i<H; i++){
        if(y_town[i]<1) flg1=false;
    }

    if(!flg&&!flg1){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }

    
}
accuracy: 1
time_ms: 40
memory_kb: 4952
final_rank: 11

code_snippet: #include<bits/stdc++.h>
using namespace std;

int n,w,h;
int ch[2][200005]={0};

bool solve(){
  for(int i=0;i<=2*w;i++){
    if(i==2*w) return 1;
    if(i!=0) ch[0][i]+=ch[0][i-1];
    if(ch[0][i]<=0) break;
  }
  for(int i=0;i<=2*h;i++){
    if(i==2*h) return 1;
    if(i!=0) ch[1][i]+=ch[1][i-1];
    if(ch[1][i]<=0) break;
  }
  return 0;
}

void answer(bool ans){
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

}
accuracy: 1
time_ms: 60
memory_kb: 4656
final_rank: 17