import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int T =sc.nextInt();
while(T-->0){
int n=sc.nextInt();
Set<F> ts=new TreeSet<F>(new SORT());
// F f[] =new F[n];
for(int i=0; i<n; i++){
// Set<String>set = new TreeSet<String>();
// set.add("wangshaungyuan");
// set.add("钱书芳");
//
// Iterator it = set.iterator();
// while(it.hasNext())
// {
// System.out.println(it.next());
// }
int a=sc.nextInt();
int b=sc.nextInt();
F f =new F(a,b);
ts.add(f);
}
// Iterator it = ts.iterator();
// while(it.hasNext())
// {
// System.out.println(it.next());
// }
// System.out.println();
F ff[] = new F[n];
Iterator<F> it=ts.iterator();
int e=-1;
while(it.hasNext()){
ff[++e]=it.next();
}
int count=1;
int nn=ff[0].b;
int mm;
for(int i=0;i<n;i++){
mm=ff[i].a;
if(nn<mm){
nn=ff[i].b;
count++;
}
}
System.out.println(count);
}
}
}
class SORT implements Comparator<F>{
@Override
public int compare(F a1, F a2) {
if(a1.b<=a2.b)
return -1;
return 1;
}
}
class F{
int a,b;
F(int a,int b){
this.a=a;
this.b=b;
}
F(){}
}
nyoj 14 会场安排问题 java Set用法
最新推荐文章于 2023-10-02 20:00:50 发布