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标签的语法,它的作用相当于 ...
随机推荐
- FFT(快速傅里叶变换)
FFT(快速傅里叶变换) 前置知识 \(1.复数\) \(2.单位根\) \(3.循环结构\) \(4.C++\) 1.复数 \(定义:形如a+bi的数,其中i^2=-1\) \(计算:1.(a+bi ...
- 父组件调用子组件 viewChild
父组件调用子组件 1.在子组件的ts中声明一个变量 public lineout:any="你好,我是被父组件调用的子组件"; 2.在父组件的html中写入 (引入子组件) & ...
- Eureka的集群配置
1:步骤说明 2:修改映射配置 3:修改Eureka的.yml配置文件 以其中一个为例 4:在8001中同时注册 5:测试结果
- scala高级部分--题目1
给你一个集合val list=List(1,2,3,4,"abc"),请完成如下要求 将集合list中所有的数字+1,并返回一个新的集合 要求忽略掉非数字的 object work ...
- 迅雷极速版开启强制升级迅雷X模式,网友出招
IT之家7月13日消息 近期,不少网友反馈,迅雷极速版已经开启强制用户升级到迅雷X的模式,而且不能关闭取消,并且会默认安装到C盘上 迅雷X是迅雷最新推出的下载客户端工具,使用Electron软件框架完 ...
- 如何将云上的Linux文件自动备份到本地服务器
需求场景: 将云上一台Linux服务器文件备份到本地服务器,一周一备即可. 面对这样一个需求,我们可能面临下列几个问题, 备份方式:是云服务器推文件到本地服务器写入,还是本地服务器从云服务器拉文件?这 ...
- WebRTC之框架与接口
出处:http://www.cnblogs.com/fangkm/p/4370492.html 上一篇文章简单地介绍了下WebRTC的协议流程,这一篇就开始介绍框架与接口. 一提到框架,本能地不知道从 ...
- C#中的System.Type和System.RuntimeType之间的区别
string str = string.Empty; Type strType = str.GetType(); Type strTypeType = strType.GetType(); strTy ...
- c#在sqlserver中使用EF框架
vs2017,sqlserver2017(localdb)调试通过.在sqlserver中创建数据库d1,表t1如下: 录入数据如下: 在vs新建任意项目,此处以控制台为例.添加数据模型Model1: ...
- 处理 unassigned shard
#查看所有分片 GET _cat/shards curl 10.1.2.2:9200/_cat/indices/iis_log* #查看索引的分片状态 #查看第一个unassigned shard的 ...