记录编号 139497 评测结果 AAAAAAAAAA
题目名称 [NOIP 2014]无线网路发射器选址 最终得分 100
用户昵称 GravatarAsm.Def 是否通过 通过
代码语言 C++ 运行时间 0.003 s
提交时间 2014-11-12 16:23:37 内存使用 0.36 MiB
显示代码纯文本
/*======================================================*/
/*========================ASM.DEF=======================*/
/*======================================================*/
#include <cstdio>
#include <cctype>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#if defined WJX_Asm_Def_DEBUG
FILE *in = fopen("test", "r");
#define out stdout
#else
FILE *in = fopen("wireless.in", "r");
FILE *out = fopen("wireless.out", "w");
#endif
inline bool getd(int &x){
	int c = fgetc(in);
	bool minus = 0;
	while(c != '-' && c != EOF && !isdigit(c))c = fgetc(in);
	if(c == EOF)return 0;
	if(c == '-'){
		x = 0;
		minus = 1;
	}
	else x = c - '0';
	while(isdigit(c = fgetc(in)))x = x * 10 - '0' + c;
	return 1;
}
/*===========================================================*/
const int maxn = 135;
int pub[maxn][maxn] = {0}, S[maxn][maxn] = {0};
int d, n;
inline void init(){
	getd(d), getd(n);
	int x, y;
	while(n--){
		getd(x), getd(y);
		getd(pub[x+1][y+1]);
	}
	for(x = 1;x <= 129;++x)//2-d Suffix
		for(y = 1;y <= 129;++y)
			S[x][y] = S[x-1][y] - S[x-1][y-1] + S[x][y-1] + pub[x][y];
}

inline void work(){
	int Max = 0, cnt = 0, i, j, i1, j1, i2, j2, s;
	for(i = 1;i <= 129;++i)
		for(j = 1;j <= 129;++j){
			i1 = i - d - 1, j1 = j - d - 1;//可以覆盖边线
			i2 = i + d, j2 = j + d;
			if(i1 < 0)i1 = 0;
			if(j1 < 0)j1 = 0;
			if(i2 > 129)i2 = 129;
			if(j2 > 129)j2 = 129;
			s = S[i2][j2] - S[i1][j2] - S[i2][j1] + S[i1][j1];
			if(s > Max)Max = s, cnt = 1;
			else if(s == Max)++cnt;
		}
	fprintf(out, "%d %d\n", cnt, Max);
}

int main(){
	
	init();
	
	work();
	
	#if defined WJX_Asm_Def_DEBUG
	cout << (double)clock() / CLOCKS_PER_SEC << endl;
	#endif
	return 0;
}