NOIP2014 無線網路發射器選址 解題報告(水題)
阿新 • • 發佈:2019-02-08
線上評測:
http://codevs.cn/problem/3578/
整體思路:
他怎麼說,你就怎麼做,不要在意n^2*m^2一樣能過,
失誤之處:
無
體會心得:
水題一定要認證做,不要想noip2015T1那樣陣列開小什麼之類的,
AC程式碼:
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 |
#include <cstdio> #include <cmath>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;
int d,n,x,y,k,mp[150][150],maxn,tot;
queue < int > dl;
int main()
{
scanf ( "%d%d" ,&d,&n);
for ( int i = 1;i <= n;i++)
{
scanf ( "%d%d%d" ,&x,&y,&k); mp[x][y] = k;
}
for ( int i = 0;i <= 128;i++)
{
for ( int j = 0;j <= 128;j++)
{
int ans = 0;
for ( int o = max(0,i - d);o <= min(128,i + d);o++)
{
for ( int p = max(0,j - d);p <= min(128,j + d);p++)
{
ans += mp[o][p];
}
}
maxn = max(maxn,ans);
if (ans == maxn) dl.push(ans);
}
} while (!dl.empty())
{
if (dl.front() == maxn) tot++;
dl.pop();
}
printf ( "%d %d\n" ,tot,maxn);
return 0;
}
|