// This is free and unencumbered software released into the public domain. // Anyone is free to copy, modify, publish, use, compile, sell, or // distribute this software, either in source code form or as a compiled // binary, for any purpose, commercial or non-commercial, and by any // means. // In jurisdictions that recognize copyright laws, the author or authors // of this software dedicate any and all copyright interest in the // software to the public domain. We make this dedication for the benefit // of the public at large and to the detriment of our heirs and // successors. We intend this dedication to be an overt act of // relinquishment in perpetuity of all present and future rights to this // software under copyright law. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. // IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // OTHER DEALINGS IN THE SOFTWARE. // For more information, please refer to /****************/ /* template.hpp */ /****************/ #include #include #include #include #include #include using std::cerr; using std::cout; using std::endl; using std::max; using std::min; using std::swap; struct BoolName : std::numpunct { std::string t, f; BoolName(std::string t, std::string f) : t(t), f(f) {} std::string do_truename() const { return t; } std::string do_falsename() const { return f; } }; void setBoolName(std::string t, std::string f) { cout.imbue(std::locale(cout.getloc(), new BoolName(t, f))); } struct Initializer { Initializer() { cout << std::fixed << std::setprecision(15) << std::boolalpha; setBoolName("Yes", "No"); } } initializer; struct Input { bool eof; Input() : eof(false) {} operator char() { char v; while (!(this->eof = (std::scanf("%c", &v) != 1)) && std::isspace(v)) { } return v; } operator int() { int v; this->eof = (std::scanf("%d", &v) != 1); return v; } operator long() { long v; this->eof = (std::scanf("%ld", &v) != 1); return v; } operator long long() { long long v; this->eof = (std::scanf("%lld", &v) != 1); return v; } operator unsigned int() { unsigned int v; this->eof = (std::scanf("%u", &v) != 1); return v; } operator unsigned long() { unsigned long v; this->eof = (std::scanf("%lu", &v) != 1); return v; } operator unsigned long long() { unsigned long long v; this->eof = (std::scanf("%llu", &v) != 1); return v; } operator double() { double v; this->eof = (std::scanf("%lf", &v) != 1); return v; } operator long double() { long double v; this->eof = (std::scanf("%Lf", &v) != 1); return v; } void ignore() const { getchar(); } } in; template T abs(T a) { return a >= 0 ? a : -a; } template bool chmin(T &a, const S &b) { return a > b ? a = b, true : false; } template bool chmax(T &a, const S &b) { return a < b ? a = b, true : false; } template std::function cast() { return [](const T &t) { return static_cast(t); }; } template T copy(const T &a) { return T(a); } class ZeroPadding { public: ZeroPadding(int n) : n(n) {} int n; }; std::ostream &operator<<(std::ostream &os, const ZeroPadding &z) { os << std::setw(z.n) << std::setfill('0'); return os; } template constexpr T inf() { return std::numeric_limits::max() / 2 - 1; } /**********************/ /* priority_queue.hpp */ /**********************/ #include template class Comp { public: bool operator()(const T &a, const T &b) const { return less ? a < b : !(a < b); } }; template class PriorityQueue : public std::priority_queue, Comp> { private: using Queue = std::priority_queue, Comp>; public: PriorityQueue() : Queue() {} PriorityQueue(const std::initializer_list &s) : Queue(s) {} T top() { T res = Queue::top(); Queue::pop(); return res; } T peek() const { return Queue::top(); } void pop() const { assert(false); } }; /*************/ /* tuple.hpp */ /*************/ #include template class Tuple : public std::tuple { public: Tuple(Input &in) : std::tuple() { (void)in; } }; template class Tuple : public std::tuple { public: Tuple() : std::tuple() {} Tuple(T t, S... s) : std::tuple(t, s...) {} Tuple(const std::tuple &t) : std::tuple(t) {} Tuple(Input &in) { auto a = std::tuple(in); std::tuple b = Tuple(in); std::tuple c = std::tuple_cat(a, b); *this = c; } template auto &get() { return std::get(*this); } template const auto &get() const { return std::get(*this); } }; template Tuple makeTuple(const T &... args) { return Tuple(args...); } namespace std { template class tuple_size> : public std::integral_constant {}; template class tuple_element> { public: using type = tuple_element_t>; }; } // namespace std /************/ /* main.cpp */ /************/ int main() { setBoolName("YES", "NO"); int n(in), m(in); PriorityQueue, false> que; for (int i = 0; i < n; ++i) { int l(in), r(in); if (l > m - r - 1) { que.emplace(m - r - 1, m - l - 1); } else { que.emplace(l, r); } } int t = -1; while (!que.empty()) { auto now = que.top(); que.pop(); if (t >= now.get<0>()) { if (now.get<0>() >= m - now.get<1>() - 1) { cout << false << endl; return 0; } que.emplace(m - now.get<1>() - 1, m - now.get<0>() - 1); } else { t = now.get<1>(); } } cout << true << endl; }