https://vjudge.net/contest/297216?tdsourcetag=s_pctim_aiomsg#problem/E
#include<bits/stdc++.h>
using namespace std;
struct note
{
int x,y,id;
} m[1005];
int f[1005];
int c[1005];
set<int> s;
bool cmp(note a,note b)
{
return a.x<b.x;
}
int main()
{
int cnt=0;
int x,y;
while(cin>>x>>y)
{
m[++cnt].x=x;
m[cnt].y=y;
m[cnt].id=cnt;
}
sort(m+1,m+1+cnt,cmp);
for(int i=1; i<=cnt; i++)
for(int j=1; j<i; j++)
{
if(m[i].y<m[j].y&&m[i].x>m[j].x&&f[i]<f[j]+1)
{
f[i]=f[j]+1;
c[i]=j;
}
}
int flag=1;
int maxx=f[1];
for(int i=2;i<=cnt;i++)
{
if(f[i]>maxx)
{
maxx=f[i];
flag=i;
}
}
while(flag!=0)
{
s.insert(flag);
flag=c[flag];
}
printf("%d\n",s.size());
for(auto i:s)
printf("%d\n",m[i].id);
// s.insert(m[flag].id);
// while(c[flag]!=0)
// {
// s.insert(m[c[flag]].id);
// flag=c[flag];
// }
// printf("%d\n",s.size());
// for(auto i:s)
// printf("%d\n",i);
}