#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
struct st { int a, b, c; };
int c[1000001];
list<st>p;
int dp[1000001];
int main() {
int n; scanf("%d", &n);
memset(c, -1, sizeof(c));
rep(i, n) {
int a, b; scanf("%d%d", &a, &b);
c[b] = max(c[b], a);
p.push_back({ a,b,i + 1 });
}
for (int i = 1000000; i > 0; i--) {
dp[i - 1] = max(dp[i - 1], dp[i]);
if (~c[i])dp[c[i]] = max(dp[c[i]], dp[i] + 1);
}
printf("%d\n", dp[0]);
int s = 0;
while (dp[s]) {
if (s)printf(" ");
for (auto it = p.begin(); it != p.end(); it++) {
if (s > it->a)it = p.erase(it);
if (s <= it->a&&dp[it->b] == dp[s] - 1) {
printf("%d", it->c); s = it->b;
p.erase(it); break;
}
}
}
puts("");
}
./Main.cpp: In function ‘int main()’:
./Main.cpp:10:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int n; scanf("%d", &n);
^
./Main.cpp:13:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
int a, b; scanf("%d%d", &a, &b);
^