题目:

 

代码~:感谢土蛋

 #include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <complex> #define lc k << 1
#define rc k << 1 | 1 #define inf 0x3f3f3f3f using namespace std;
typedef long long ll; int a[][];
int n, m, p; ll mn = 1e13, mx = ; inline int dis(int x1, int y1, int x2, int y2){
return min(abs(x2 - x1) + abs(y2 - y1), p);
} void solve(int x){
int y = ;
ll lres = , rres = ;
ll lsum = , rsum = ;
for(int i = x - p; i <= x + p; i ++){
for(int j = y - p; j <= y; j ++){
if(dis(i, j, x, y) != p) lsum += a[i + ][j + ]; lres += a[i + ][j + ] * (p - dis(i, j, x, y));
}
}
for(int i = x - p; i <= x + p; i ++){
for(int j = y + ; j <= y + p; j ++){
if(dis(i, j, x, y) != p) rsum += a[i + ][j + ]; rres += a[i + ][j + ] * (p - dis(i, j, x, y));
}
}
//printf("%d %d %lld %lld %lld %lld\n", x, y, lres, rres, lsum, rsum);
mn = min(lres + rres, mn);
mx = max(mx, lres + rres);
while(y < m){
lres -= lsum;
for(int i = y - p + ; i <= y; i ++){
lsum -= a[x + (p - - y + i) + ][i + ];
if(p - - y + i != ) lsum -= a[x - (p - - y + i) + ][i + ];
}
y ++;
for(int i = y; i <= y + p - ; i ++){
rsum += a[x + (p - - i + y) + ][i + ];
if(p - - i + y != ) rsum += a[x - (p - - i + y) + ][i + ];
}
rres += rsum;
for(int i = x - p + ; i <= x + p - ; i ++){
rsum -= a[i + ][y + ]; rres -= a[i + ][y + ] * (p - dis(i, y, x, y));
lsum += a[i + ][y + ]; lres += a[i + ][y + ] * (p - dis(i, y, x, y));
}
// printf("%d %d %lld %lld %lld %lld\n", x, y, lres, rres, lsum, rsum);
mn = min(lres + rres, mn);
mx = max(mx, lres + rres);
}
} int main(){
freopen("rts.in", "r", stdin);
freopen("rts.out", "w", stdout); scanf("%d%d%d", &n, &m, &p);
memset(a, , sizeof(a));
for(int i = ; i <= n; i ++){
for(int j = ; j <= m; j ++){
scanf("%d", &a[i + ][j + ]);
//a[i + 200][j + 200] = 1;
}
}
for(int i = ; i <= n; i ++){
solve(i);
}
printf("%lld %lld\n", mn, mx);
return ;
}

Problem B. 即时战略 ———2019.10.12的更多相关文章

  1. Problem A. 最近公共祖先 ———2019.10.12

    我亲爱的学姐冒险跑去为我们送正解 但是,,,, 阿龙粗现了! cao,, 考场期望得分:20   实际得分:20 Problem A. 最近公共祖先 (commonants.c/cpp/pas) 最近 ...

  2. Problem C. 欧皇 ————2019.10.12

    题目: 再次感激土蛋 #include <bits/stdc++.h> using namespace std; typedef long long ll; ; ll C[][]; voi ...

  3. jQuery进阶第三天(2019 10.12)

    一.原生JS快捷的尺寸(属性)(注意这些属性的结果 不带PX单位) clientWidth/clientHeight  =====> 获得元素content+padding的宽/高: offse ...

  4. 【CSP-S膜你考】即时战略(模拟)

    Problem B. 即时战略 (rts.c/cpp/pas) 注意 Input file: rts.in Output file: rts.out Time Limit : 2 seconds Me ...

  5. D3D游戏编程系列(三):自己动手编写即时战略游戏之寻路

    说起即时战略游戏,不得不提的一个问题是如何把一个物体从一个位置移动到另一个位置,当然,我说的不是瞬移,而是一个移动的过程,那么在这个移动的过程中我们如何来规划路线呢,这就不得不提到寻路了. 我所了解到 ...

  6. 2019年12月的第一个bug

    现在是2019年12月1日0点27分,我的心情依旧难以平静.这个月是2019年的最后一个月,是21世纪10年代的最后一个月,也是第一批90后30岁以前的最后一个月.就是在这个月的第一天的0点0分,我写 ...

  7. 【转帖】Intel AMD 龙芯2019年12月份最新产品线

    Intel未来三代U集体曝光:14nm退回去了! https://news.cnblogs.com/n/651244/ 不过没搞懂 为啥中芯国际已经开始量产14nm了 龙芯为什么不用.. 3A4000 ...

  8. TIZ_c 第0周总结(2019/10/15-2019/10/22)工欲善其事必先利其器

    TIZ_c 第0周总结(2019/10/15-2019/10/22)工欲善其事必先利其器 任务清单 给自己取一个酷酷的id,并选择1-2个喜欢的方向.(只是初步选择,后期可更改) 改下群名片.例如yo ...

  9. 36.React基础介绍——2019年12月24日

    2019年12月24日16:47:12 2019年10月25日11:24:29 主要介绍react入门知识. 1.jsx语法介绍 1.1 介绍 jsx语法是一种类似于html标签的语法,它的作用相当于 ...

随机推荐

  1. 前端开发vscode必备插件

    VSCode 插件 Atom one Dark Theme Atom Dark主题 Auto Close Tag 自动关闭标签 Auto Rename Tag 自动重命名标签 Beautify 格式化 ...

  2. GitHub的高级搜索功能

    1. 首先,提供Github高级搜索帮助页面https://help.github.com/categories/search/     2. 搜索语法https://help.github.com/ ...

  3. 《STL源码剖析》——Vector

    vector vector的源码分为多个文件:vector.<<stl_vector.h>> vector的底层实现是在<<stl_vector.h>> ...

  4. 一般处理程序Session

    1.要在一般处理程序中获取其他页面的session值,需要引用名空间: using System.Web.SessionState; 2.然后继承一个接口:IRequiresSessionState ...

  5. 一个类搞定SQL条件映射解析,实现轻量简单实用ORM功能

    个人觉得轻简级的ORM既要支持强类型编码,又要有执行效率,还要通俗易懂给开发者友好提示,结合Expression可轻松定制自己所需要功能. Orm成品开源项目地址https://github.com/ ...

  6. Delphi - Logs记录,函数实现MsgDsp

    Logs记录-函数实现MsgDsp 大多数时候,我们不太希望消息以交互的形式出现,这个时候我们可以在窗体上放置一个Memo,然后单独开一个线程进行监视,从而实现把消息实时的显示出来,便于开发者分析. ...

  7. spring data jpa hql动态查询案例

    目的:根据入参条件不同,动态组装hql里的where语句. 1. 实现代码 public List<WrapStatis> queryStatisCriteriaBuilder(Strin ...

  8. rabbitMq 学习笔记(一)

    消息队列中间件是分布式系统中重要的组件,主要解决应用耦合,异步消息,流量削锋等问题 实现高性能,高可用,可伸缩和最终一致性架构. RabbitMQ 是采用 Erlang 语言实现 AMQP (Adva ...

  9. webuploader-异步切片上传(暂不支持断点续传)及 下载方法!C#/.NET

    十年河东,十年河西,莫欺少年穷 学无止境,精益求精 进入正题: 关于webuploader,参考网址:https://fex.baidu.com/webuploader/: 本篇博客范例下载地址:ht ...

  10. MYSQL中IN,INSTR,FIND_IN_SET函数效率比较(转)

    今天写代码时前台传过来类似‘1,2,3,4,5,6’的字符串,这种情况直接用IN是无效的,需要把字符串分割成数组或者组装成列表,然后再利用mabatis的foreach函数 <select id ...