Problem B. 即时战略 ———2019.10.12
题目:
















代码~:感谢土蛋
#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的更多相关文章
- Problem A. 最近公共祖先 ———2019.10.12
我亲爱的学姐冒险跑去为我们送正解 但是,,,, 阿龙粗现了! cao,, 考场期望得分:20 实际得分:20 Problem A. 最近公共祖先 (commonants.c/cpp/pas) 最近 ...
- Problem C. 欧皇 ————2019.10.12
题目: 再次感激土蛋 #include <bits/stdc++.h> using namespace std; typedef long long ll; ; ll C[][]; voi ...
- jQuery进阶第三天(2019 10.12)
一.原生JS快捷的尺寸(属性)(注意这些属性的结果 不带PX单位) clientWidth/clientHeight =====> 获得元素content+padding的宽/高: offse ...
- 【CSP-S膜你考】即时战略(模拟)
Problem B. 即时战略 (rts.c/cpp/pas) 注意 Input file: rts.in Output file: rts.out Time Limit : 2 seconds Me ...
- D3D游戏编程系列(三):自己动手编写即时战略游戏之寻路
说起即时战略游戏,不得不提的一个问题是如何把一个物体从一个位置移动到另一个位置,当然,我说的不是瞬移,而是一个移动的过程,那么在这个移动的过程中我们如何来规划路线呢,这就不得不提到寻路了. 我所了解到 ...
- 2019年12月的第一个bug
现在是2019年12月1日0点27分,我的心情依旧难以平静.这个月是2019年的最后一个月,是21世纪10年代的最后一个月,也是第一批90后30岁以前的最后一个月.就是在这个月的第一天的0点0分,我写 ...
- 【转帖】Intel AMD 龙芯2019年12月份最新产品线
Intel未来三代U集体曝光:14nm退回去了! https://news.cnblogs.com/n/651244/ 不过没搞懂 为啥中芯国际已经开始量产14nm了 龙芯为什么不用.. 3A4000 ...
- TIZ_c 第0周总结(2019/10/15-2019/10/22)工欲善其事必先利其器
TIZ_c 第0周总结(2019/10/15-2019/10/22)工欲善其事必先利其器 任务清单 给自己取一个酷酷的id,并选择1-2个喜欢的方向.(只是初步选择,后期可更改) 改下群名片.例如yo ...
- 36.React基础介绍——2019年12月24日
2019年12月24日16:47:12 2019年10月25日11:24:29 主要介绍react入门知识. 1.jsx语法介绍 1.1 介绍 jsx语法是一种类似于html标签的语法,它的作用相当于 ...
随机推荐
- Rollup 配置 es6 环境
前 为了可以使用新型的语法,顺便在兼容下老的浏览器,所以需要自己搭建个环境,目前我个人推崇使用 rollup,主要喜欢它的 tree-shake,打包出来的代码真的很简洁. 配置 rollup.con ...
- python做一个简易图片下载工具
代码有点乱,先这样 # -*- coding:utf-8 -*- #__author__ :kusy #__content__:文件说明 #__date__:2018/11/01 11:01 impo ...
- 【More Effective C++ 条款2】最好使用C++转型操作符
C的转型方式存在以下两个缺点: 1)几乎允许你将任何类型转化为任何类型,不能精确的指明转型意图,这样很不安全 如将一个pointer-to-base-class-object转型为一个pointer- ...
- Django学习——全局templates引用的问题
一.问题在构建网站的时候我们会用到全局的templates处理错误的网页,此时我们需要对urls进行一个映射,使得在使用的时候避免重复调用.在使用的时候还会产生错误代码:第一个是404界面的,第二个是 ...
- 【ELK】7. elasticsearch linux上操作es命令详解
========== 1.检查ES节点是否正常启动 curl http://192.168.6.16:9200 正常状态: 非正常状态: 1>确保服务是不是正常启动了,端口用的是哪个 2> ...
- MVC+Ninject+三层架构+代码生成 -- 总结(三、實體類)
一.動軟代碼生成器生成 實體類 2.VS視圖--實體類,其中Condition文件夾是存放 搜索的分頁信息 using System; using System.Collections.Generic ...
- Qt高仿Excel表格组件-支持冻结列、冻结行、内容自适应和合并单元格
目录 一.概述 二.效果展示 三.实现思路 1.冻结行.冻结列 2.行高自适应 3.蚂蚁线 四.测试代码 1.添加表格数据 2.设置冻结行.列 3.行高.列宽 4.单元格背景色 5.单元格文字 6.其 ...
- android studio学习----通过gradle来导入jar包
转载地址:http://www.th7.cn/Program/Android/201507/495477.shtml File->Project Structure 可以打开下面的图: 1.通过 ...
- druid获取不需要配置公钥私钥的密文,或者明文
import com.alibaba.druid.filter.config.ConfigTools; /** * Created with IntelliJ IDEA on 2019/3/21. * ...
- Mysql-修改用户连接数据库IP地址和用户名
将用户连接数据库(5.7.14-7)的IP地址从 10.10.5.16 修改为 10.11.4.197 Mysql> rename user 'username'@'10.10.5.16' ...