Pagini recente » Cod sursa (job #3139807) | Cod sursa (job #2937478) | Cod sursa (job #1425140) | Cod sursa (job #2530128) | Cod sursa (job #39809)
Cod sursa(job #39809)
#include<stdio.h>
#include<algorithm>
using namespace std;
const int maxn = 1001;
int i;
int n;
int j;
int nrd, nrp;
int a[maxn], b[maxn], c[maxn];
int x[maxn], y[maxn];
int mat[maxn][maxn];
int ind[maxn];
int nr;
double calca(double x1,double y1,double x2,double y2, double x3,double y3)
{
return x1 * y2 + x2 * y3 + y3 * x1 - y1 * x2 - y2 * x3 - x3 * y1;
}
bool cmpf(const int i,const int j)
{
int x;
for(x = 1;x <= nrd; ++x)
{
if (mat[i][x] < mat[j][x]) return true;
if (mat[i][x] > mat[j][x]) return false;
}
return true;
}
bool egal(int i, int j)
{
int x;
for(x = 1;x <= nrd; ++x)
{
if (mat[i][x] != mat[j][x]) return false;
}
return true;;
}
int main()
{
freopen("regiuni.in","r",stdin);
freopen("regiuni.out","w",stdout);
scanf("%d %d",&nrd,&nrp);
for(i = 1;i <= nrd; ++i)
{
scanf("%d %d %d",&a[i],&b[i],&c[i]);
}
for(i = 1;i <= nrp; ++i)
{
scanf("%d %d",&x[i],&y[i]);
ind[i] = i;
}
for(i = 1;i <= nrd; ++i)
{
double x1 = 1;
double y1 = (-c[i] - a[i] * x1) / b[i];
double x2 = 1;
double y2 = (-c[i] - a[i] * x2) / b[i];
for(j = 1;j <= nrp; ++j)
{
if (calca(x1,y1,x2,y2,x[j],y[j]) < 0) mat[j][i] = 1;
else
{
mat[j][i] = 0;
}
}
}
sort(ind + 1,ind + nrp + 1, cmpf);
int max = 0;
for(i = 1;i <= nrp; ++i)
{
if (egal(ind[i],ind[i - 1]))nr++;
else
{
if (max < nr) max = nr;
nr = 1;
}
}
if (max < nr) max = nr;
printf("%d\n",max);
return 0;
}