Why WA5?? :((
Послано
DAVE 12 июн 2007 12:10
#include <stdio.h>
#include <math.h>
int X,Y,L,E,P;
struct NAV
{
int x,y,h,e,x1,x2,y1,y2;
};
NAV Nav[50];
int V[30100],H[30100];
int Max(int a, int b)
{
if (a>b) return a;
return b;
}
int OKH(int x,int y)
{
int i,k=1,j;
for (j=0; j<L; ++j)
for (i=0; i<E; ++i)
if ((y>=Nav[j].y1) && (y<=Nav[j].y2))
if ((x+i>=Nav[j].x1) && (x+i<=Nav[j].x2))
return 0;
return 1;
}
int OKV(int x,int y)
{
int i,k=1,j;
for (j=0; j<L; ++j)
for (i=0; i<E; ++i)
if ((x>=Nav[j].x1) && (x<=Nav[j].x2))
if ((y+i>=Nav[j].y1) && (y+i<=Nav[j].y2))
return 0;
return 1;
}
int main()
{
int i,j;
scanf("%d %d %d",&Y,&X,&L);
for (i=0; i<L; ++i)
{
scanf("%d %d %d %c",&Nav[i].x,&Nav[i].y,&Nav[i].e,&Nav[i].h);
if (Nav[i].h=='V')
{
for (j=-1; j<=Nav[i].e; ++j) V[Nav[i].y+j]=1;
H[Nav[i].x-1]=H[Nav[i].x]=H[Nav[i].x+1]=1;
Nav[i].x1=Nav[i].x-1;
Nav[i].y1=Nav[i].y-1;
Nav[i].x2=Nav[i].x+1;
Nav[i].y2=Nav[i].y+Nav[i].e;
}
else
{
for (j=-1; j<=Nav[i].e; ++j) H[Nav[i].x+j]=1;
V[Nav[i].y-1]=V[Nav[i].y]=V[Nav[i].y+1]=1;
Nav[i].x1=Nav[i].x-1;
Nav[i].y1=Nav[i].y-1;
Nav[i].x2=Nav[i].x+Nav[i].e;
Nav[i].y2=Nav[i].y+1;
}
}
scanf("%d",&E);
for (j=1; j<=Y; ++j)
{
if (V[j]>0)
{
for (i=1; i<=X-E+1; ++i)
if (OKH(i,j)) P++;
}
else
{
P+=X-E+1;
}
}
if (E>1)
for (i=1; i<=X; ++i)
{
if (H[i]>0)
{
for (j=1; j<=Y-E+1; ++j)
if (OKV(i,j)) P++;
}
else
{
P+=Y-E+1;
}
}
printf("%d",P);
return 0;
}