viernes, 18 de noviembre de 2011

10360 - Rat Attack, uva

#include<iostream>
#include<cstring>
#include<vector>
#include<utility>
#define db(a) cout << #a << " = " << a << endl
#define db2(a, b) cout << #a << " = " << a << " " << #b << " = " << b << endl
int killed[1025][1025];
using namespace std;
int main() {
 int s, d, n, x, y, tam;
 cin >> s;
 for (int i = 0; i < s; i++) {
  memset(killed, 0, sizeof killed);
  cin >> d >> n;
  for (int j = 0; j < n; j++) {
   cin >> x >> y >> tam;
   for (int u = x - d; u <= x + d; u++)
    for (int v = y - d; v <= y + d; v++) {
     if (u >= 0 && u <= 1024 && v >= 0 && v <= 1024) killed[u][v] += tam;
    }
  }
  int maxi = 0;
  for (int u = 0; u <= 1024; u++)
    for (int v = 0; v <= 1024; v++) {
     if (maxi < killed[u][v]) {
      maxi = killed[u][v];
      x = u;
      y = v;
     }
    }
  cout << x << " " << y << " " << maxi << endl;
 }
 return 0;
}

No hay comentarios:

Publicar un comentario