#include<iostream>
using namespace std;
int g[129][129];
int main()
{
int d;
int n;
cin >> d >> n;
for (int i = 1;i <= n;i++)
{
int x, y, k;
cin >> x >> y >> k;
g[x][y] = k;
}
int max1 = -1;
int max2 = -1;
for (int i = 0;i <= 128;i++)
{
for (int j = 0;j <= 128;j++)
{
int sum = 0;
for (int z = (i - d >= 0) ? (i - d) : 0;z <= (i + d <= 128 ? i + d : 128);z++)
{
for (int v = (j - d >= 0) ? (j - d) : 0;v <= (j + d <= 128 ? j + d : 128);v++)
{
sum += g[z][v];
}
}
if (sum > max2)
{
max2 = sum;
max1 = 1;
}
else if (sum == max2)
{
max1++;
}
}
}
cout << max1 << " " << max2 << endl;
return 0;
}
//浅醉喝 做法
#include<iostream>
using namespace std;
int g[130][130];
int s[130][130];
int d, n;
int main()
{
cin >> d >> n;
for (int i = 1;i <= n;i++)
{
int x, y, k;
cin >> x >> y >> k;
g[x+1][y+1] = k;
}
for (int i = 1;i <= 129;i++)
{
for (int j = 1;j <= 129;j++)
{
s[i][j] = s[i][j - 1] + s[i - 1][j] - s[i - 1][j - 1] + g[i][j];
}
}
//cout << s[7][7] - s[5-1][7] - s[7][5-1] + s[5-1][5-1] << "qwq";
int max1 = -1;
int max2 = -1;
for (int i = 1;i <= 129;i++)
{
for (int j = 1;j <= 129;j++)
{
int sum = 0;
int r1 = (i - d >= 1 ? i - d : 1);//上
int r2 = (i + d <= 129 ? i + d : 129);//下
int r3 = (j - d >= 1 ? j - d : 1);//左
int r4 = (j + d <= 129 ? j + d : 129);//右
sum = s[r2][r4] - s[r2][r3-1] - s[r1-1][r4] + s[r1-1][r3-1];
if (sum > max2)
{
max2 = sum;
max1 = 1;
}
else if(max2==sum)
{
max1++;
}
}
}
cout << max1 << " " << max2 << endl;
return 0;
}
#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;
char g[20][20];
int n;
int y[20];
int x[20];
int main()
{
cin >> n;
double rx, ry, lx, ly, ox, oy, flag = 0;
for (int j = n;j >=1;j--)
{
for (int i = 1;i <= n;i++)
{
cin >> g[j][i];
if (g[j][i] == '1')
{
x[i]++;
y[j]++;
}
if (g[j][i] == 'x')
{
if (flag == 0)
{
rx = i;
ry = j;
flag = 1;
}
else
{
lx = i;
ly = j;
}
}
}
}
int xx = 0, yy = 0;
for (int i = 1;i <=19;i++)
{
if (x[i] > xx)
{
xx = x[i];
ox = i;
}
if (y[i] > yy)
{
yy = y[i];
oy = i;
}
}
int xxx = rx;
int yyy = ry;
int cnt = 0;
if (g[yyy + 1][xxx] == '1')
{
cnt++;
}
if (g[yyy - 1][xxx] == '1')
{
cnt++;
}
if (g[yyy ][xxx-1] == '1')
{
cnt++;
}
if (g[yyy ][xxx+1] == '1')
{
cnt++;
}
if (cnt >= 3)
{
ox = rx;
oy = ry;
}
xxx = lx;
yyy = ly;
cnt = 0;
if (g[yyy + 1][xxx] == '1')
{
cnt++;
}
if (g[yyy - 1][xxx] == '1')
{
cnt++;
}
if (g[yyy][xxx - 1] == '1')
{
cnt++;
}
if (g[yyy][xxx + 1] == '1')
{
cnt++;
}
if (cnt >= 3)
{
ox = lx;
oy = ly;
}
//cout << lx << " " << ly << " " << rx << " " << ry << endl;
if (ly == ry)
{
cout << "y=";
cout << fixed << setprecision(4) << ly - oy << endl;
return 0;
}
else if (lx == rx)
{
cout << "x=";
cout << fixed << setprecision(4) << lx - ox << endl;
}
else
{
double k = (ly - ry) / (lx - rx);
double b = (ry-oy) - (k * (rx-ox));
cout << "y=";
cout << fixed << setprecision(4) << k;
cout << 'x';
if (b != 0)
{
if (b > 0)
{
cout << "+";
}
cout << fixed << setprecision(4) << b << endl;
}
}
return 0;
}