#pragma GCC optimize ("O3") #pragma GCC target ("avx") #include "bits/stdc++.h" // define macro "/D__MAI" using namespace std; typedef long long int ll; #define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout< ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout< ostream& operator <<(ostream &o, const pair p) { o << "(" << p.first << ":" << p.second << ")"; return o; } #define TIME chrono::system_clock::now() #define MILLISEC(t) (chrono::duration_cast(t).count()) namespace { std::chrono::system_clock::time_point ttt; void tic() { ttt = TIME; } void toc() { fprintf(stderr, "TIME : %lldms\n", MILLISEC(TIME - ttt)); } std::chrono::system_clock::time_point tle = TIME; #ifdef __MAI void safe_tle(int msec) { assert(MILLISEC(TIME - tle) < msec); } #else #define safe_tle(k) ; #endif } #ifdef __MAI #define getchar_unlocked getchar #define putchar_unlocked putchar #endif #ifdef __VSCC #define getchar_unlocked _getchar_nolock #define putchar_unlocked _putchar_nolock #endif namespace { #define isvisiablechar(c) (0x21<=(c)&&(c)<=0x7E) class MaiScanner { public: template void input_integer(T& var) { var = 0; T sign = 1; int cc = getchar_unlocked(); for (; cc<'0' || '9'>(int& var) { input_integer(var); return *this; } inline MaiScanner& operator>>(long long& var) { input_integer(var); return *this; } inline MaiScanner& operator>>(string& var) { int cc = getchar_unlocked(); for (; !isvisiablechar(cc); cc = getchar_unlocked()); for (; isvisiablechar(cc); cc = getchar_unlocked()) var.push_back(cc); } }; } MaiScanner scanner; class Graph { public: size_t n; vector> vertex_to; vector> vertex_from; Graph(size_t n) :n(n), vertex_to(n), vertex_from(n) {} void connect(int from, int to) { vertex_to[from].emplace_back(to); vertex_from[to].emplace_back(from); } void resize(size_t _n) { n = _n; vertex_to.resize(_n); vertex_from.resize(_n); } }; class sat_2 { public: size_t n; Graph graph; sat_2(size_t n) :n(n), graph(n * 2 + 1) { } private: inline int _cv(int v) { return 0& ord, vector &num, int k) { if (0 <= num[v]) return; num[v] = k; for (int to : graph.vertex_to[v]) { _scc_dfs1(to, ord, num, k); } ord.push_back(v); } void _scc_dfs2(int v, vector &num, int k) { if (num[v] < 0) return; num[v] = -k; for (int to : graph.vertex_from[v]) { _scc_dfs2(to, num, k); } } public: // 1 <= a <= n OR -1 >= a >= -n // 正ならばx_a,負ならばNOT x_aを表現. inline void emplace(int a, int b) { // assert(a!=0 && b!=0); graph.connect(_cv(-a), _cv(b)); graph.connect(_cv(-b), _cv(a)); } bool solve(vector& result) { int i; vector num(graph.n, -1), ord; ord.reserve(graph.n + 1); for (i = 0; i> n >> m; repeat(n) { scanner >> lr[cnt][0] >> lr[cnt][1]; } sat_2 sat(n); for (int i = 0; i < n - 1; ++i) { int vl = m + 1 - lr[i][1]; int vr = m + 1 - lr[i][0]; for (int j = i + 1; j < n; ++j) { if ((lr[i][0] <= lr[j][0] && lr[i][1] >= lr[j][0]) || (lr[i][0] <= lr[j][1] && lr[i][1] >= lr[j][1])) { sat.emplace((i + 1), -(j + 1)); sat.emplace(-(i + 1), (j + 1)); } if ((vl <= lr[j][0] && vr >= lr[j][0]) || (vl <= lr[j][1] && vr >= lr[j][1])) { sat.emplace((i + 1), (j + 1)); sat.emplace(-(i + 1), -(j + 1)); } } } vector result; if (sat.solve(result)) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }