#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <set>
#include <string.h>
using namespace std;
//int map[1025][1025];
int ans[1025][1025];
struct Point {
int x;
int y;
int cl;
Point(int x_,int y_,int cl_):x(x_),y(y_),cl(cl_){}
};
bool operator<(Point a, Point b) {
return a.cl > b.cl;
}
int main()
{
int T;
cin >> T;
while (T--) {
int d, n;
cin >> d >> n;
//memset(map, 0, sizeof(map));
memset(ans, 0, sizeof(ans));
multiset<Point> m;
for (int I = 0; I < n; I++) {
int x, y, i;
cin >> x >> y >> i;
for (int x_ = x - d; x_ <= x + d; x_++) {
if (x_ < 0)
continue;
if (x_ > 1024)
break;
for (int y_ = y - d; y_ <= y + d; y_++) {
if (y_ < 0)
continue;
if (y_ > 1024)
break;
ans[x_][y_] += i;
m.insert(Point(x_, y_, ans[x_][y_]));
}
}
}
int num = 0;
for (multiset<Point>::iterator i = m.begin(); i != m.end(); i++) {
if (i->cl!=m.begin()->cl)
break;
num++;
}
cout << num <<' '<< m.begin()->cl << endl;
}
return 0;
}
[Coursera]算法基础_Week9_考试_Q1
最新推荐文章于 2019-03-26 17:37:11 发布