-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy path10360.cpp
86 lines (81 loc) · 1.51 KB
/
10360.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define MAXN 1027
int Field[MAXN][MAXN];
int rad, MaxR, MaxC, MaxRat;
void Select(int x, int y, int rat) {
if(x > MaxR) return;
if(x < MaxR) {
MaxR = x;
MaxC = y;
return;
}
if(x == MaxR) {
if(y > MaxC) return;
MaxC = y;
}
}
void Set(int x, int y, int rat) {
int tempx, tempy, i, j;
tempx = x - rad;
tempy = y - rad;
for (i = tempx; i<= x + rad; i++) {
if (i < 0) continue;
if (i > 1024) break;
for (j = tempy; j <= y + rad; j++){
if (j < 0) continue;
if (j > 1024) break;
Field[i][j] += rat;
if (Field[i][j] > MaxRat) {
MaxR = i;
MaxC = j;
MaxRat = Field[i][j];
}
else if (Field[i][j] == MaxRat)
Select(i, j, Field[i][j]);
}
}
}
int main() {
int kase, popu;
int i, x, y, rat;
scanf("%d", &kase);
while (kase--) {
scanf("%d", &rad);
scanf("%d", &popu);
MaxRat = 0;
MaxR = MaxC = 1024;
for (i = 0; i < popu; i++){
scanf("%d%d%d",&x, &y, &rat);
Set(x, y, rat);
}
printf("%d %d %d\n",MaxR, MaxC, MaxRat);
for (i = 0; i <= 1025; i++)
memset(Field[i],0,sizeof(int)*1026);
}
return 0;
}