链接
#include <stdio.h>
struct time
{
int begin;
int over;
}soft[10000];
void qsort(struct time a[], int l, int r) // 快排
{
if (l < r)
{
int i = l, j = r, x = a[l].over; // x 是一个具体的数 用int就行
struct time y = a[l]; // 临时变量得用 结构体类型
while (i < j )
{
while (i < j && a[j].over >= x)
j--;
if (i < j)
a[i++] = a[j];
while (i < j && a[i].over < x)
i++;
if (i < j)
a[j--] = a[i];
}
a[i] = y;
qsort(a, l, i-1);
qsort(a, i+1, r);
}
}
int main()
{
int i, j, t, n, count;
int b[10000];
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for (i = 0; i < n; i++)
scanf("%d%d",&soft[i].begin, &soft[i].over);
qsort(soft, 0, n-1);
/* for (i = 0; i < n; i++)
printf("%d %d\n",soft[i].begin, soft[i].over);
*/
count = 1;
b[1] = soft[0].over;
for (i = 0; i < n-1; i++)
{
if (soft[i+1].begin > b[count])
{
count++;
b[count] = soft[i+1].over;
}
}
printf("%d\n",count);
}
return 0;
}