显示代码纯文本
#include<fstream>
using namespace std;
ifstream cin("HWsweepclassroom.in");
ofstream cout("HWsweepclassroom.out");
int n,m,ans=0;
int section[300002],counter[300001],draw[100001][2],answer[100001];
int main()
{
cin>>n>>m;
for(int i=1;i<=m;i++)
{
cin>>draw[i][0]>>draw[i][1];
section[draw[i][0]]++;
section[draw[i][1]+1]--;
}
int times=0;
for(int i=1;i<=n;i++)
{
times+=section[i];
section[i]=times;
}
for(int i=1;i<=n;i++)
{
if(section[i]>1)
{
counter[i]=counter[i-1]+1;
}
else
{
counter[i]=counter[i-1];
}
}
for(int i=1;i<=m;i++)
{
if(counter[draw[i][1]]-counter[draw[i][0]-1]==draw[i][1]-draw[i][0]+1)
{
answer[++ans]=i;
}
}
cout<<ans<<endl;
for(int i=1;i<=ans;i++)
{
cout<<answer[i]<<' ';
}
cin.close();
cout.close();
return 0;
}