Pagini recente » Cod sursa (job #848315) | Cod sursa (job #2844932) | Cod sursa (job #1877663) | Cod sursa (job #1619713) | Cod sursa (job #29632)
Cod sursa(job #29632)
/*#include "stdafx.h"
#include "infoarena.h"
#include <conio.h>/**/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <map>
#include <set>
using namespace std;
#define _OGRAZI_
#ifdef _OGRAZI_
#ifndef _INC_CONIO
void clrscr()
{
freopen("ograzi.out", "w", stdout);
}
void getch() {}
#else
void clrscr() {}
#endif
#define rep(i,n) for(i=0;i<n;i++)
#define min(a,b) (((a) < (b)) ? (a) : (b))
typedef pair<int, int> Coord;
typedef map<int, Coord> YMap;
typedef map<int, YMap> XYMap;
XYMap a;
int main()
{
int n,m,w,h;
int i;
int count=0;
char buf[100];
memset(buf, 0, sizeof(buf));
clrscr();
FILE *fin = fopen("ograzi.in", "r");
fscanf(fin, "%d %d %d %d\n",&n,&m,&w,&h);
rep(i, n)
{
int x = 0, y = 0, i;
fgets(buf, '\n', fin);
for(i = 0; isdigit(buf[i]); i++)
{
x *= 10; x+= buf[i] - '0';
}
for(++i; isdigit(buf[i]); i++)
{
y *= 10; y+= buf[i] - '0';
}
int xh = x / w, yh = y / h;
XYMap::iterator ix;
YMap::iterator iy;
ix = a.find(xh);
if (ix != a.end())
{
iy = ix->second.find(yh);
if (iy != ix->second.end()) { int *p = NULL; *p=1;}
}
a[xh][yh] = Coord(x,y);
}
rep(i, m)
{
int x = 0, y = 0, i;
XYMap::iterator ix;
YMap::iterator iy;
fgets(buf, '\n', fin);
for(i = 0; isdigit(buf[i]); i++)
{
x *= 10; x+= buf[i] - '0';
}
for(++i; isdigit(buf[i]); i++)
{
y *= 10; y+= buf[i] - '0';
}
int xh = x / w, yh = y / h;
ix = a.find(xh);
if (ix != a.end())
{
iy = ix->second.find(yh);
if (iy != ix->second.end() && iy->second.first <= x && iy->second.second <= y)
{
count++;
continue;
}
iy = ix->second.find(yh-1);
if (iy != ix->second.end() && iy->second.first <= x && iy->second.second >= y - h)
{
count++;
continue;
}
}
ix = a.find(xh-1);
if (ix != a.end())
{
iy = ix->second.find(yh);
if (iy != ix->second.end() && iy->second.first >= x-w && iy->second.second <= y)
{
count++;
continue;
}
iy = ix->second.find(yh-1);
if (iy != ix->second.end() && iy->second.first >= x-w && iy->second.second >= y - h)
{
count++;
continue;
}
}
}
printf("%d", count);
getch();
return 0;
}
#endif