Pagini recente » Cod sursa (job #298424) | Cod sursa (job #2407150) | Cod sursa (job #582302) | Cod sursa (job #1545348) | Cod sursa (job #1735964)
#include <iostream>
#include <fstream>
#include <map>
#define a first
#define b second
#define mp make_pair
using namespace std;
FILE* fin=fopen("ograzi.in","r");
const unsigned maxb=8192;
char buf[maxb];
unsigned ptr=maxb;
inline unsigned getInt(){
unsigned nr=0;
while(buf[ptr]<'0'||'9'<buf[ptr])
if(++ptr>=maxb)
fread(buf,maxb,1,fin),ptr=0;
while('0'<=buf[ptr]&&buf[ptr]<='9'){
nr=nr*10+buf[ptr]-'0';
if(++ptr>=maxb)
fread(buf,maxb,1,fin),ptr=0;
}
return nr;
}
map< pair<int, int>, pair<int, int> > mt;
int n, m, w, h;
inline bool ino(int x, int y)
{
for(int i = 0; i <= 1; ++i)
for(int j = 0; j <= 1; ++j)
{
if(mt.find(mp(x/w - i, y/h - j)) != mt.end())
{
pair<int, int> coord = mt[mp(x/w - i, y/h - j)];
if((coord.a+w >= x && coord.b+h >= y) && (coord.a <= x && coord.b <= y))
return 1;
}
}
return 0;
}
int main()
{
ofstream g("ograzi.out");
n = getInt();
m = getInt();
w = getInt();
h = getInt();
for(int i = 1; i <= n; ++i)
{
int x, y;
x = getInt();
y = getInt();
mt[mp(x/w, y/h)] = mp(x, y);
}
int nr = 0;
for(int i = 1; i <= m; ++i)
{
int x, y;
x = getInt();
y = getInt();
nr += ino(x, y);
}
g << nr;
}