#include #include #include using namespace std; #define pb push_back int N, K; struct team_info { int s, p, u, point, irank; }; vector t; vector ans; int successt[100005]; bool comp1(const team_info &t1, const team_info &t2) { if(t1.s != t2.s) return t1.s > t2.s; return t1.p < t2.p; } bool comp2(const team_info &t1, const team_info &t2) { if(t1.s != t2.s) return t1.s > t2.s; if(t1.irank != t2.irank) return t1.irank < t2.irank; return t1.p < t2.p; } int main(void) { cin.tie(0); ios::sync_with_stdio(false); int S, P, U; team_info ti; cin >> N >> K; for (int i = 0; i < N; i++) { cin >> S >> P >> U; ti.s = S; ti.p = P; ti.u = U; ti.point = i; t.pb(ti); } sort(t.begin(), t.end(), comp1); /*for(int i = 0; i < N; i++) { cout << t[i].s << " " << t[i].p << " " << t[i].u << endl; }*/ for(int i = 0 ; i < N; i++) { t[i].irank = successt[t[i].u]++; } sort(t.begin(), t.end(), comp2); for (int i = 0; i < K; i++) { cout << t[i].point << endl; } return 0; }