11942022-03-15 19:14:15vandrasHadjáratcpp14Accepted 100/100108ms36776 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = (1<<18);

struct point{
	int x, y, id;
	bool operator<(const point& o) const{
		return x < o.x;
	}
};

int n, p[N];
set<point> last[N];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;

	last[0].insert({0,0,0});
	int totmx=0, mxpos;

	for(int i = 1; i <= n; ++i){
		int x, y, mx=0; cin >> x >> y;

		for(int j = 17; j >= 0; --j){
			int nmx = mx + (1<<j);

			auto it = last[nmx].lower_bound({x,y,-1});
			if(it != last[nmx].begin()){
				--it;
				if(it->y >= y) continue;
				mx = nmx;
				p[i] = it->id;
			}
		}

		++mx;
		auto it = last[mx].lower_bound({x,y,-1});	

		while(it != last[mx].end() && it->y >= y) it = last[mx].erase(it);
		if(it == last[mx].end() || it->x != x) last[mx].insert({x,y,i});

		if(mx > totmx){
			totmx = mx;
			mxpos = i;
		}
	}

	cout << totmx << '\n';
	vector<int> res;
	while(mxpos){
		res.push_back(mxpos);
		mxpos = p[mxpos];
	}
	for(int i = res.size()-1; i >=0; --i) cout <<res[i] << ' ';
	cout << '\n';
	
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base100/100
1Accepted0/016ms26400 KiB
2Accepted0/056ms27796 KiB
3Accepted4/413ms27020 KiB
4Accepted4/412ms27020 KiB
5Accepted4/413ms27028 KiB
6Accepted4/413ms27076 KiB
7Accepted4/413ms27024 KiB
8Accepted4/413ms27040 KiB
9Accepted4/414ms27044 KiB
10Accepted4/417ms27068 KiB
11Accepted4/417ms27260 KiB
12Accepted4/419ms27492 KiB
13Accepted6/619ms27604 KiB
14Accepted6/628ms27896 KiB
15Accepted6/637ms28424 KiB
16Accepted6/652ms29156 KiB
17Accepted6/665ms30180 KiB
18Accepted6/675ms31232 KiB
19Accepted6/682ms32444 KiB
20Accepted6/6108ms34056 KiB
21Accepted6/6104ms35440 KiB
22Accepted6/6104ms36776 KiB