题目:

 

代码~:感谢土蛋

 #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. 通过JS下载 or 唤起App

    判断唤起app的连接是否在WeChat中打开 let isWeiXin = navigator.userAgent.toLowerCase().indexOf('micromessenger') != ...

  2. Redis学习之ziplist压缩列表源码分析

    一.压缩列表ziplist在redis中的应用 1.做列表键 当一个列表键只包含少量列表项,并且每个列表项要么是小整数,要么是短字符串,那么redis会使用压缩列表作为列表键的底层实现 2.哈希键 当 ...

  3. 如何解决aws解绑银行卡问题?

    首先先来说明一下我自己的情况? 一年的免费使用 前提:没有开启任何的实例服务 先贴一条官方的解释 关于我小白一个.学校课程要求使用aws,注册之后在网络上看到一堆人踩坑,aws的扣费就是个坑! 预授权 ...

  4. nginx报错111: Connection refused

    最近遇到了nginx疯狂抛错,access.log一天一共5W多条,但error.log中有大概9K多条,基本都是111: Connection refused,这到底是为什么呢? 从日志看起 我们还 ...

  5. R数据挖掘 第三篇:聚类的评估(簇数确定和轮廓系数)和可视化

    在实际的聚类应用中,通常使用k-均值和k-中心化算法来进行聚类分析,这两种算法都需要输入簇数,为了保证聚类的质量,应该首先确定最佳的簇数,并使用轮廓系数来评估聚类的结果. 一,k-均值法确定最佳的簇数 ...

  6. win10系统优化

    1.服务:关闭 windows update\ windows search \ windows 备份 2.系统:高级系统设置->性能最优,同事修改虚拟内存如下 3.任务管理器:关闭多余的启动项 ...

  7. redis 实战操作RDB和AOF快照持久化

    前言:redis是我们常用的缓存方式,今天就来介绍下两种持久化的方式吧,先科普概念,再实战操作 一.RDB Redis将某一时刻的快照(备份的数据库数据)保存成一种称为RDB格式的文件中,这种格式是经 ...

  8. rabbitMq 学习笔记(一)

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

  9. html5权威指南:组织内容、文档分节

    HTML5新增及删除标签:http://www.cnblogs.com/starof/archive/2015/06/23/4581850.html 第九章:组织内容                 ...

  10. java request.getInputStream中文乱码解决方案

    请求时要指定为UTF-8,中文码码完美解决 /** * * 得到请求body字符串,一般用于content-type:application/json * */ public static Strin ...