0
已解决
宋灏
初级光能
初级光能
题目链接: 酷町堂:1803
#include <iostream>
#include <cstdio>
#pragma GCC optimize(3)
using namespace std;
int d, n, ti, ans;
int a[3000][3000];
int b[3000][3000];
int maxx, minx = 11111111, maxy, miny = 11111111;
int sum(int x, int y) {
int cnt = 0;
for (int i = x - d; i <= x + d; i ++) {
for (int j = y - d; j <= y + d; j ++) {
cnt += a[i][j];
}
}
return cnt;
}
void flag(int x, int y) {
for (int i = x - d; i <= x + d; i ++) {
for (int j = y - d; j <= y + d; j ++) {
b[i][j] = 1;
}
}
}
int main() {
scanf("%d",&d);
scanf("%d",&n);
for (int i = 1; i <= n; i ++) {
int x, y, z;
scanf("%d%d%d",&x,&y,&z);
a[x][y] = z;
flag(x, y);
maxx = max(maxx, x);
maxy = max(maxy, y);
minx = min(minx, x);
miny = min(miny, y);
}
for (int i = max(minx - d, 0 + d); i <= min(maxx + d, 1024 - d); i ++) {
for (int j = max(miny - d, 0 + d); j <= min(maxx + d, 1024 - d); j ++) {
if (b[i][j] == 0) {
continue;
}
int x = sum(i, j);
if (x > ans) {
ans = x;
ti = 1;
} else if (x == ans) {
ti ++;
}
}
}
printf("%d ",ti);
printf("%d",ans);
return 0;
}
求大佬解答???
为啥会错??