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标签的语法,它的作用相当于 ...
随机推荐
- SpringBoot系列之profles配置多环境(篇一)
SpringBoot profles配置多环境 23/100 发布文章 u014427391 软件环境简介 这里介绍一下SpringBoot提供的profiles属性加上maven配置一下多环境,在实 ...
- go-gin-api 规划目录和参数验证(二)
概述 首先同步下项目概况: 上篇文章分享了,使用 go modules 初始化项目,这篇文章咱们分享: 规划目录结构 模型绑定和验证 自定义验证器 制定 API 返回结构 废话不多说,咱们开始吧. 规 ...
- MyBatis 通过 BATCH 批量提交
本文由 简悦 SimpRead 转码, 原文地址 https://www.jb51.net/article/153382.htm 很多人在用 MyBatis 或者 通用 Mapper 时,经常会问有没 ...
- day06——小数据池、深浅拷贝、集合
day06 小数据池 小数据池--缓存机制(驻留机制),只是一种规格,不会实际的开辟一个空间 == 判断两边内容是否相等 ***** # a = 10 # b = 10 # print(a == b) ...
- Postman安装使用
下载链接:https://www.getpostman.com/downloads/ 选择下载的版本 postman基础功能介绍 collection在postman里面相当于一个文件夹,可以把同一个 ...
- sql server 分页总结
1.第一种方式:使用 ROW_NUMBER() OVER(ORDER BY ID) …… BETWEEN AND 的方式SELECT * FROM( SELECT ROW_NUMBER() OVER( ...
- 新一代ActiveMQ —— Apache ActiveMQ Artemis
资料: .net demo : https://github.com/apache/activemq-artemis/tree/master/examples/protocols/amqp/dotne ...
- 在微博微信场景下学习Redis数据结构
Redis安装 下载地址:http://redis.io/download 安装步骤: 1.yum install gcc 2.wget http://download.redis.io/releas ...
- 连root也干不掉的文件
在你的印象中,是不是root用户就可以为所欲为呢?随便一个rm -rf *,一波骚操作走人?可能没那么容易. 来啊,删我啊! 先来个示例,创建一个文本文件test.txt $ touch test.t ...
- rabbitMq 学习笔记(一)
消息队列中间件是分布式系统中重要的组件,主要解决应用耦合,异步消息,流量削锋等问题 实现高性能,高可用,可伸缩和最终一致性架构. RabbitMQ 是采用 Erlang 语言实现 AMQP (Adva ...