#include using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define fth(t) std::get<3>(t) using ll = long long; using P = std::tuple; using P3 = std::tuple; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; int N, K, nxt[100000], prv[100000]; P ps[100000]; std::vector us[100000]; std::priority_queue, greater

> pq; int main(){ //* std::cin.tie(nullptr); std::ios::sync_with_stdio(false); /*/ /*/ std::cin >> N >> K; for(int i=0;i> fst(ps[i]) >> snd(ps[i]) >> thd(ps[i]); fst(ps[i]) = -fst(ps[i]); fth(ps[i]) = i; } sort(ps, ps+N); int n = 0; for(int i=0,j=0;i is; while(j < N && fst(ps[j]) == fst(ps[i])){ int p, u, index; tie(ignore, p, u, index) = ps[j]; us[u].emplace_back(p, u, index); is.emplace_back(u); ++j; } sort(is.begin(), is.end()); is.erase(unique(is.begin(), is.end()), is.end()); for(int u : is){ sort(us[u].begin() + prv[u], us[u].end()); pq.push(std::make_tuple(nxt[u], fst(us[u][nxt[u]]), snd(us[u][nxt[u]]), thd(us[u][nxt[u]]))); ++nxt[u]; prv[u] = us[u].size(); } int _n = 0; while(_n < j - i){ int u, index; tie(ignore, ignore, u, index) = pq.top(); pq.pop(); printf("%d\n", index); if(++n == K){return 0;} if(nxt[u] < us[u].size()){ pq.push(std::make_tuple(nxt[u], fst(us[u][nxt[u]]), snd(us[u][nxt[u]]), thd(us[u][nxt[u]]))); ++nxt[u]; } ++_n; } i = j; } }