1 #include<iostream> 2 #define MAXN 10001 3 using namespace std; 4 5 struct _node 6 { 7 int b; 8 int e; 9 }; 10 11 void discreat(int l,int r,int index); 12 _node _m[MAXN]; 13 int n; 14 bool boo; 15 int main() 16 { 17 //freopen("acm.acm","r",stdin); 18 int test; 19 int i; 20 int ans; 21 //cin>>test; 22 scanf("%d",&test); 23 while(test --) 24 { 25 ans = 0; 26 //cin>>n; 27 scanf("%d",&n); 28 for(i = 0; i < n; ++ i) 29 { 30 //cin>>_m[i].b>>_m[i].e; 31 scanf("%d%d",&_m[i].b,&_m[i].e); 32 } 33 for(i = 0; i < n; ++ i) 34 { 35 boo = false; 36 discreat(_m[i].b,_m[i].e,i+1); 37 if(boo) 38 ++ ans; 39 } 40 cout<<ans<<endl; 41 } 42 } 43 44 void discreat(int l,int r,int index) 45 { 46 if(index == n) 47 { 48 boo = true; 49 return; 50 } 51 if(l >= _m[index].b && r <= _m[index].e) 52 { 53 return; 54 } 55 if(r < _m[index].b || l > _m[index].e) 56 { 57 discreat(l,r,index + 1); 58 return; 59 } 60 if(l < _m[index].b) 61 { 62 discreat(l,_m[index].b - 1,index + 1); 63 //return 0; 64 } 65 if(r > _m[index].e) 66 { 67 discreat(_m[index].e + 1,r,index + 1); 68 } 69 return; 70 }