#include<stdio.h>
#include<string.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<math.h>
#include<queue>
#include<functional>
#define P pair<int,int>
using namespace std;
int BIT[1000002];
int MAX(int a) {//(1,a)の最大値
int ans = 0;
while (a > 0) {
ans = max(ans, BIT[a]);
a -= a&-a;
}
return ans;
}
void update(int b, int c) {//BIT[b]をcにする
while (b < 1000002) {
BIT[b] = max(BIT[b], c);
b += b&-b;
}
}
struct S {
int h, o, ID, K;
};
S d[100000];
int K[100000];
signed main() {
int e; scanf("%d", &e);
for (int f = 0; f < e; f++) {
int g, h; scanf("%d%d", &g, &h);
d[f] = { g + 1,h + 1,f };
}
sort(d, d + e, [](S a, S b) {if (a.h != b.h)return a.h < b.h; return a.ID < b.ID; });
for (int i = 0; i < e; i++) {
d[i].K = MAX(d[i].h) + 1;
update(d[i].o, d[i].K);
}
sort(d, d + e, [](S a, S b) {if (a.K != b.K)return a.K > b.K; return a.ID < b.ID; });
vector<int>ans;
int now = 1 << 29;
for (int i = 0; i < e; i++) {
if (now >= d[i].o) {
now = d[i].h;
ans.push_back(d[i].ID);
}
}
reverse(ans.begin(), ans.end());
cout << ans.size() << endl;
for (int i = 0; i < ans.size(); i++) {
if (i)cout << " ";
cout << ans[i] + 1;
}
cout << endl;
}
./Main.cpp: In function ‘int main()’:
./Main.cpp:37:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int e; scanf("%d", &e);
^
./Main.cpp:39:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int g, h; scanf("%d%d", &g, &h);
^