# 新龟兔赛跑

1x只乌龟同时超过一只兔子   乌龟一族 x

2x只兔子同时超过一只乌龟   兔子一族 x

3x只乌龟同时超过y只兔子   乌龟一族 x*y

4x只兔子同时超过y只乌龟   兔子一族 x*y

``````3
3 5
7 6
8 2
1 7
2 6
5 8
2
4 2
5 2
3 4
2 4
``````

``````7
4
``````

``````#include<stdio.h>
int main()
{
int n,i,j,sum;
int a[1000][2],b[1000][2];
while(scanf("%d",&n)==1)
{
sum=0;
for(i=0;i<n;i++)
scanf("%d%d",&a[i][0],&a[i][1]);
for(i=0;i<n;i++)
scanf("%d%d",&b[i][0],&b[i][1]);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
if(b[j][0]<a[i][0]&&b[j][1]>a[i][1])
{
sum=sum+1;
sum=sum%2012;
}
}
printf("%d\n",sum);
}

return 0;
}
``````

``````#include <iostream>
#include <cstdio>
#include <algorithm>
#include <memory.h>
#include <math.h>
#define Tortoise 1
#define Rabbit   2
using namespace std;
struct type
{
int s,v,kind;
} Racer[100000];
int n;
bool cmp(type a,type b)
{
return a.s>b.s;
}
int rabNum[100001];
int lowbit(int x)
{
return x&(-x);
}
long long int getNum(int x)
{
long long int sum=0;
for(; x>0; x-=lowbit(x))
sum+=rabNum[x];
return sum;
}
{
for(; x<=100000; x+=lowbit(x))
rabNum[x]+=val;
}
int main()
{
long long int ans;
while(cin>>n)
{
ans=0;
memset(rabNum,0,sizeof(rabNum));
for(int i=0; i<n; ++i)
{
cin>>Racer[i].s>>Racer[i].v;
Racer[i].kind=Rabbit;
}
for(int i=n; i<(n<<1); ++i)
{
cin>>Racer[i].s>>Racer[i].v;
Racer[i].kind=Tortoise;
}
sort(Racer,Racer+(n<<1),cmp);
for(int i=0; i<(n<<1); ++i)
{
if(Racer[i].kind==Rabbit)
else if(Racer[i].kind==Tortoise)
ans=(ans+getNum(Racer[i].v-1))%2012;
}
cout<<ans<<endl;
}
return 0;
}

``````