贪心,和会议安排完全一样,感觉贪心很水呀,应该是还没有遇见难的
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct p
{
int x, y;
int i;
} node[1001];
int cmp(const void *a, const void *b)
{
p *aa = (p*)a, *bb = (p*)b;
return aa->y - bb->y;
}
int main ()
{
int i, j, k;
int n;
while(scanf("%d", &n) && n)
{
for(i=0; i<n; i++)
{
scanf("%d%d", &node[i].x, &node[i].y);
node[i].i = i+1;
}
qsort(node, n, sizeof(node[0]), cmp);
int end = 0;
for(i=0; i<n; i++)
{
if(node[i].x >= end)
{
printf(i==0 ? "%d" : " %d", node[i].i);
end = node[i].y;
}
}
printf("\n");
}
return 0;
}