Pagini recente » Cod sursa (job #2687066) | Cod sursa (job #147040) | Cod sursa (job #416636) | Cod sursa (job #600246) | Cod sursa (job #201595)
Cod sursa(job #201595)
#include<fstream.h>
#define dim 200002
ifstream f("hvrays.in");
ofstream g("hvrays.out");
unsigned long h,v,cont,aux,max,pmax;
int t;
struct punct
{
unsigned long x;
unsigned long y;
int tip;
};
punct a[dim],man;
void sort()
{
unsigned long i,ok,nn,poz;
ok=0;
nn=aux-1;
do
{ok=0;
for(i=1;i<=nn;i++)
if(a[i].x<a[i+1].x)
{
man=a[i];
a[i]=a[i+1];
a[i+1]=man;
ok=1;
poz=i;
}
nn=poz;
}
while(ok);
}
int main()
{
unsigned long i;
f>>t;
while(t)
{
f>>h>>v;
aux=h+v;
for(i=1;i<=h;i++)
{
f>>a[i].x>>a[i].y;
a[i].tip=0;
}
for(i=h+1;i<=aux;i++)
{
f>>a[i].x>>a[i].y;
a[i].tip=1;
}
sort();
for(i=1;i<=aux;i++)
{
if( a[i].tip==1 && a[i].y>pmax )
pmax=a[i].y;
else if( !a[i].tip )
{
if( a[i].y>max )
{
max=pmax;
cont++;
}
}
}
g<<cont<<'\n';
t--;
}
f.close();
g.close();
return 0;
}