Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <string>
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <stack>
- #include <queue>
- #include <deque>
- #include <set>
- #include <map>
- #include <cmath>
- #include <unordered_map>
- #include <unordered_set>
- #include <numeric>
- #include <fstream>
- #include <functional>
- #include <iomanip>
- #include <cctype>
- #include <iterator>
- #include <utility>
- #include <bitset>
- #include <tuple>
- #define frt(s, n, t) for(int i = s; (i > n && t < 0) || (i < n && t > 0); i += t)
- #define fr(s, n) for (int i = s; i < n; i++)
- #define frj(s, n) for (int j = 0; j < n; j++)
- #define eol "\n"
- #define pb push_back
- #define ft first
- #define sd second
- using namespace std;
- typedef long long unsigned ull;
- typedef long long ll;
- typedef unordered_map<int, int> umii;
- typedef unordered_set<int> usi;
- typedef unordered_set<ll> usll;
- typedef unordered_set<ull> usull;
- typedef vector<int> vint;
- typedef pair<int, int> pairI;
- typedef pair<string, int> psi;
- typedef vector<pair<int, int>> vpi;
- int main() {
- //ifstream in("input.txt");
- //ofstream out("output.txt");
- ios::sync_with_stdio(0);
- cin.tie(NULL);
- pair<vector<pairI>, vector<pairI>> arr[200001];
- int n, m, k, x, y;
- cin >> n >> k;
- vector<pairI> v(n);
- int maxG = 0;
- fr(0, n) {
- cin >> v[i].ft >> v[i].sd;
- maxG = max(maxG, v[i].sd);
- arr[v[i].ft].ft.pb({ v[i].sd, i });
- arr[v[i].sd].sd.pb({ v[i].sd, i });
- }
- set<pairI> s;
- vint r;
- fr(0, maxG+1) {
- for (auto x : arr[i].ft) {
- if (v[x.sd].first > 0)
- s.insert(x);
- }
- while (s.size() > k) {
- pairI last = *(--s.end());
- s.erase(--s.end());
- v[last.sd].first = -1;
- r.push_back(last.sd);
- }
- for (auto x : arr[i].sd) {
- if (v[x.sd].first > 0)
- s.erase(x);
- }
- }
- cout << r.size() << eol;
- for (int x : r) {
- cout << x+1 << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement