#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using Int = long long; template ostream &operator<<(ostream &os, const pair &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; } template bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; } template bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; } namespace MCF { #define MAXN 100010 #define MAXM 100010 #define wint int #define cint Int const wint wEPS = 0; const wint wINF = 1001001001; const cint cEPS = 0; const cint cINF = 1001001001001001001LL; int n, m, ptr[MAXN], next[MAXM], zu[MAXM]; wint capa[MAXM], tof; cint cost[MAXM], toc, d[MAXN], pot[MAXN]; int vis[MAXN], pree[MAXN]; void init(int _n) { n = _n; m = 0; memset(ptr, ~0, n << 2); } void ae(int u, int v, wint w, cint c) { next[m] = ptr[u]; ptr[u] = m; zu[m] = v; capa[m] = w; cost[m] = +c; ++m; next[m] = ptr[v]; ptr[v] = m; zu[m] = u; capa[m] = 0; cost[m] = -c; ++m; } bool solve(int src, int ink, wint flo = wINF) { wint f; cint c, cc; int i, u, v; memset(pot, 0, n * sizeof(cint)); /* for (bool cont = 1; cont; ) { cont = 0; for (u = 0; u < n; ++u) for (i = ptr[u]; ~i; i = next[i]) if (capa[i] > wEPS) { if (pot[zu[i]] > pot[u] + cost[i] + cEPS) { pot[zu[i]] = pot[u] + cost[i]; cont = 1; } } } //*/ for (toc = 0, tof = 0; tof + wEPS < flo; ) { typedef pair node; priority_queue< node,vector,greater > q; for (u = 0; u < n; ++u) { d[u] = cINF; vis[u] = 0; } for (q.push(make_pair(d[src] = 0, src)); !q.empty(); ) { c = q.top().first; u = q.top().second; q.pop(); if (vis[u]++) continue; for (i = ptr[u]; ~i; i = next[i]) if (capa[i] > wEPS) { cc = c + cost[i] + pot[u] - pot[v = zu[i]]; if (d[v] > cc) { q.push(make_pair(d[v] = cc, v)); pree[v] = i; } } } if (!vis[ink]) return 0; f = flo - tof; for (v = ink; v != src; v = zu[i ^ 1]) { i = pree[v]; chmin(f, capa[i]); } for (v = ink; v != src; v = zu[i ^ 1]) { i = pree[v]; capa[i] -= f; capa[i ^ 1] += f; } tof += f; toc += f * (d[ink] - pot[src] + pot[ink]); for (u = 0; u < n; ++u) pot[u] += d[u]; } return 1; } } int N; Int M; vector A, B, C; int main() { for (; ~scanf("%d%lld", &N, &M); ) { A.resize(N); B.resize(N); C.resize(N); for (int i = 0; i < N; ++i) { scanf("%lld%lld%lld", &A[i], &B[i], &C[i]); } for (int i = 0; i < N; ++i) { if (A[i] > C[i]) { swap(A[i], C[i]); } } vector bs = B; sort(bs.begin(), bs.end()); bs.erase(unique(bs.begin(), bs.end()), bs.end()); const int bsLen = bs.size(); // cerr<<"bs = ";pv(bs.begin(),bs.end()); MCF::init(2 + N + N + bsLen + bsLen); int score = 0; for (int i = 0; i < N; ++i) { score += B[i]; score += C[i]; } for (int i = 0; i < N; ++i) { MCF::ae(0, 2 + i, 1, 0); } for (int i = 0; i < N; ++i) { // b < A[i] { const int j = lower_bound(bs.begin(), bs.end(), A[i]) - bs.begin() - 1; // cerr<= "<= M) ? "KADOMATSU!" : "NO"); } else { puts("NO"); } } return 0; }