2012杭州赛区(浙江理工大学)J - Scaring the Birds

MuJoCo柔性体仿真实战:从FlexComp建模到自定义模型导入 柔性体仿真是机器人交互研究中不可或缺的一环,MuJoCo作为高精度物理求解器,凭借高效的求解速度与批量并行能力,成为强化学习与软体抓取任务的热门选择。其FlexComp机制将连续材料离散为粒子-约束系统,以较低建模成本模拟布料、软组织等形变行为,相比Gazebo等平台更具实时性与可扩展性。技术价值体现在自定义柔性体建模与导入流程中:通过XML配置网格密度、间距与材料参数,即可生成贴合任务需求的软体垫子或硅胶抓手。在柔性抓取、颗粒抓手、医疗仿真等场景中,该方法能快速构建可训练的环境。围绕环境搭建、FlexCo 阅读详情

2012杭州现场赛
2:08:19
5:00:00
                   
J - Scaring the Birds
Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Description

It’s harvest season now! 
Farmer John plants a lot of corn. There are many birds living around his corn field. These birds keep stealing his corn all the time. John can't stand with that any more. He decides to put some scarecrows in the field to drive the birds away. 
John's field can be considered as an N×N grid which has N×N intersections. John plants his corn on every intersection at first. But as time goes by, some corn were destroyed by rats or birds so some vacant intersections were left. Now John wants to put scarecrows on those vacant intersections and he can put at most one scarecrow on one intersection. Because of the landform and the different height of corn, every vacant intersections has a scaring range R meaning that if John put a scarecrow on it, the scarecrow can only scare the birds inside the range of manhattan distance R from the intersection. 



The figure above shows a 7×7 field. Assuming that the scaring range of vacant intersection (4,2) is 2, then the corn on the marked intersections can be protected by a scarecrow put on intersection (4,2). 
Now John wants to figure out at least how many scarecrows he must buy to protect all his corn.
 

Input

There are several test cases. 
For each test case: 
The first line is an integer N ( 2 <= N <= 50 ) meaning that John's field is an N×N grid. 
The second line is an integer K ( 0<= K <= 10) meaning that there are K vacant intersections on which John can put a scarecrow. 
The third line describes the position of K vacant intersections, in the format of r  1,c  1,r  2,c  2 …. r  K,c  k . (r  i,c  i) is the position of the i-th intersection and 1 <= r  1,c  1,r  2,c  2 …. r  K,c  k <= N. 
The forth line gives the scaring range of all vacant intersections, in the format of R  1,R  2…R  K and 0 <= R  1,R  2…R  K <= 2 × N. 
The input ends with N = 0.
 

Output

For each test case, print the minimum number of scarecrows farmer John must buy in a line. If John has no way to protect all the corn, print -1 instead.
 

Sample Input

        
4 2 2 2 3 3 1 3 4 2 2 2 3 3 1 4 0
 

Sample Output

        
-1 1
 


题意:题目很简单,就是n*n个点,然后某些点可以放稻草人,然后给每个稻草人的半径,问最少需要几个稻草人覆盖全部点,暴力枚举稻草人广搜就可以了。这里有个坑,可以放稻草人的地方是不需要覆盖的,一个下午没看到这个地方卡了3个小时,醉了。下面给代码。

#include<iostream>
#include<stack>
#include<cstring>
#include<map>
#include<string>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<utility>
using namespace std;
struct node {
	int x, y, value;
}p[15];
int  steparr[4][2] = { -1,0,1,0,0,-1,0,1 };
int vis[55][55],vis1[55][55];
int n;
queue<node>q;
bool bfs() {
	while (!q.empty()) {
		node now = q.front();
		q.pop();
		if (!now.value)
			continue;
		for (int i = 0; i < 4; i++) {
			int nowx = now.x + steparr[i][0];
			int nowy = now.y + steparr[i][1];
			if (nowx <= 0 || nowx > n || nowy <= 0 || nowy > n || vis[nowx][nowy] >= now.value - 1)
				continue;
			vis[nowx][nowy] = now.value - 1;
			q.push(node{ nowx,nowy ,vis[nowx][nowy] });
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (vis[i][j] == -1&&!vis1[i][j]) {
				return false;
			}
		}
	}
	return true;
}
int main() {
	while (scanf("%d", &n)) {
		if (!n)
			break;
		int k;
		scanf("%d", &k);
		memset(vis1, 0, sizeof(vis1));
		for (int i = 0; i < k; i++) {
			scanf("%d%d", &p[i].x, &p[i].y);
			vis1[p[i].x][p[i].y] = 1;
		}
		for (int i = 0; i < k; i++) {
			scanf("%d", &p[i].value);
		}
		int max = 15;
		for (int i = 0; i < (1 << k); i++) {
			memset(vis, -1, sizeof(vis));
			for (int j = 0; j < k; j++) {
				if (i&(1 << j)) {
					q.push(p[j]);
					vis[p[j].x][p[j].y] = p[j].value;
				}
			}
			int now = q.size();
			if (bfs() && now<max) {
				max = now;
			}
		}
		if (max == 15) {
			printf("-1\n");
		}
		else {
			printf("%d\n", max);
		}
	}
}

计算机控制技术及应用 《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。 立即下载

相关推荐

从手机到自动驾驶:MIPI-CSI2协议演进史与车规级改造要点

本文追溯了MIPI-CSI2协议从智能手机摄像头到自动驾驶核心传感器的演进历程。重点剖析了该协议在车规级改造中面临的严苛挑战,包括物理层稳定性、EMC防护、功能安全与数据可靠性等关键要点,并探讨了其在多传感器融合与高带宽实时传输中的工程实践。

weixin_28318011的博客 308

HDU 4462 Scaring the Birds (状态压缩 暴搞)

题意:给定了一个N*N的地图,地图上有K(0--10)个点可以放守卫,其它点有食物,每个守卫有一个R,只要其它点的食物到守卫点的曼哈顿距离在R范围内就算被保护。 问最少需要多少个守卫,使得所有食物都被保护。 看到K最多只有10,就可以状态压缩K的所有情况,枚举一遍,可行就比较一下。 有个trick:只需要所有的食物被保护就行,空地如果不放守卫未被保护也可以。 #incl

Paradiser 1048

【UE5】UE5 Dedicated Server专用服务器与网络同步

这篇文章是个人在学习UE4的网络同步方面的内容的一些记录,因为UE5出来了,顺带也一起熟悉熟悉UE5,所以也就直接使用UE5来实践了。说句实在话,UE4网络同步这块确实挺难的,我自己在网上搜索的博客的内容要么停留在很浅层面只搭建一个ds服务器,要么就直接深入源码去剖析UE4的网络机制,处在中间层面的内容少之又少,不得不自己好一阵研究,强烈推荐这几位博主的博文,我在学习的过程中也从中受益匪浅。 Ken_An、风蚀之月、 刘东无敌还有我师傅推荐给我的一本关于UE4网络的PDF。 一、什么是Dedicated

Goulandis 3万+

HDU4462(子集生成)

Scaring the Birds Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 714    Accepted Submission(s): 252 Problem Description It’s harve

李硕 1217

Office LTSC 2021/2024专业部署:ODT+config.xml标准化实战

Office部署本质上是企业终端软件生命周期管理的关键环节,其核心原理在于通过声明式配置驱动安装、激活与组件裁剪。Office Deployment Tool(ODT)作为微软官方命令行引擎,配合config.xml这一DSL契约文件,实现可版本控制、可审计、可回滚的自动化交付。该方案技术价值突出体现在稳定性保障(如LTSC长期支持通道)、合规性强化(不绕过授权机制)及运维提效(批量部署、离线支持)。典型应用场景覆盖教育机房批量装机、政企终端标准化、医疗HIS工作站部署等对功能冻结与系统确定性要求严苛的环境

diaocuiguo2493的博客 559

路径规划:D*Lite寻路算法详解

D*Lite详解目录

mkr67n的博客 2万+

hdu 4462 Scaring the Birds(STL)

题目链接:hdu 4462 Scaring the Birds 题目大意:给定N,表示有一个N∗N的农田,现在有些位置的谷物已经被毁坏,农场主决定在这些位置中选择一些放 置稻草人,给定每个点放置稻草人可以覆盖的曼哈顿距离。求最少放多少个稻草人。 解题思路:题意需要注意,可以放稻草人的位置是没有谷物的。然后对于每个位置预处理出可以覆盖的位置,用bitset 优化即可。 #i

不慌不忙、不急不躁 1087

深度学习【46】pix2pixHD

英伟达的pix2pixHD,能够合成高清的2048*1024图片,简直振奋人心。pix2pixHD是我之前介绍过的pix2pix的改进版本,使用多由粗到精的G网络和多尺度D网络(每个D网络都是用了pix2pix中同样的patch技术)。论文一开始用pix2pix尝试合成更高分辨率的图片,但发现效果不好,训练也很不稳定。所以就对pix2pix进行了一顿魔改。我们来看看他们是怎么改进的。由粗到精的G网络

DCD_LIN的博客 1万+

HDU4462.Scaring the Birds(枚举子集+二进制表示状态)

https://vjudge.net/contest/369905#problem/D 题意: 在给定位置可以放稻草人,然后稻草人在一定范围内可以保护草地,要求至少要设置多少个稻草人才可以保护所有的草地 解题思路: 因为稻草人数量不大于10,所以可以直接枚举 稻草人的使用状况可以用二进制1到1<<k-1来表示,然后对于每一种状态进行n*n的讨论即可 特别要注意,稻草人的位置不需要覆盖,...

Buyi的博客 187

告别RXTX:SpringBoot集成jSerialComm实现更现代的串口通信(附完整代码对比)

本文详细介绍了如何从传统的RXTX库迁移到jSerialComm,实现SpringBoot项目中更现代的串口通信。通过对比两种技术的依赖配置、API设计和跨平台支持,展示了jSerialComm在简化部署、提升性能和增强稳定性方面的优势,并提供了完整的代码示例和实战经验。

weixin_42522964的博客 286

RK3568下GPIO模拟串口

在嵌入式开发中,硬件 UART 资源可能被其他外设占用。此时,通过 GPIO 模拟 UART(软串口)成为一种灵活的解决方案。本文基于 RK3568 平台,结合 Linux 内核模块,实现高精度软串口通信,并深入分析关键技术细节。可以看到已经接收到数据了,可以自己创建自定义的设备文件到/dev下,也可以按照串口设备的标准创建一个设备,后面有时间我写一篇和标准串口设备结合的gpio模拟串口文章。RK3568 GPIO 模拟串口(软串口)实现详解。将编译好的驱动放到板子上运行。再写个Makefile。

文石_2009的博客 364

2012ACM 杭州邀请赛个别题目题解

B(HDU 4454) Stealing a Cake Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1795 Accepted Submission(s): 495 Problem Description Th...

weixin_30954265的博客 202

知识图谱中的 Ontology(本体论)

1980年,本体论(Ontology)哲学概念“本体”被引入到人工智能领域用来刻画知识。本体概念模型、明确、形式化、共享。本体是实体存在形式的描述,往往表示为一组概念定义和概念之间的层级关系,本体框架形式树状结构,通常被用来为知识图谱定义schema。如人、公司、车等都可以在具体场景下称为本体。Ontology是(特定领域)信息组织的一种形式,是领域知识规范的抽象和描述,是表达、共享、重用知识的方法。Ontology。

全网粉丝30W+,优快云、稀土掘金人工智能领域签约作者,人工智能、大模型、Python 爬虫,商务合作,请私信沟通。 2030

hdu 4462 Scaring the Birds【Dfs+暴力判断】

Scaring the Birds Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3523    Accepted Submission(s): 1094 Problem Description It’s harvest

mengxiang000000 506

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

hdu 4462 Scaring the Birds (暴力)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4462 题意:给你k个稻草人,

乐观之奋斗者 669

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

hdu 4462 Scaring the Birds(暴力,细读)

题意:http://acm.hdu.edu.cn/showproblem.php?pid=4462 我想说,这道题不是考验数据结构或是神马复杂的算法,就是考验人的阅读能力和思维的缜密。有两点:第一点都能看出来,当k=0时不能保护已有的庄稼;第二点,当k=n*n时,即所有的点都是没有庄稼的,直接输出0. #include #include #include using namespace

theArcticOcean 784

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

HDU4462Scaring the Birds 枚举子集

时隔很久,重拾敲代码。。。。 十一月末十二月初事情很多啊。。。 不说了,上题。 HDU4462Scaring the Birds Scaring the Birds Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 36

半夏之失_的博客 516

HDU 4462Scaring the Birds(枚举所有状态)

Scaring the Birds Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1257    Accepted Submission(s): 420 Problem Description It’s harv

布生气 1800

2016 ICPC青岛赛 hdu5984 C Pocky

Pocky Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 156    Accepted Submission(s): 68 Problem Description Let’s talking about som

overload1997 2855

2017 icpc广西邀请赛 K.Query on A Tree (hdu 6191)可持久化字典树

Query on A Tree Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others) Total Submission(s): 0    Accepted Submission(s): 0 Problem Description Monkey A liv

overload1997 1294

2017 ACM-ICPC 亚洲区(西安赛区)网络赛 G Xor lca+暴力

题目链接:https://nanti.jisuanke.com/t/17120 题意:给你一棵树,每个点都有权值,q次询问,每次询问给你a,b,k,问从点a到点b每隔k步的异或和是多少。 思路:现场没敢打,复杂度怎么算都不对。。。后来别人说可以1的情况lca其他暴力,我就试了一下,一开始是TLE,然后我各种迷之优化确实可以过。。。。走k步这里我是用了倍增的数组然后用logk的复杂度走k步。。。

overload1997 1164

2016 ICPC青岛赛 hdu5988 G.Coding Contest

Coding Contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 849    Accepted Submission(s): 156 Problem Description A coding cont

overload1997 948

2016 ICPC大连赛区 hdu5978 To begin or not to begin

To begin or not to begin Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 229    Accepted Submission(s): 175 Problem Description A b

overload1997 935

2012杭州赛区(浙江理工大学)H - Friend Chains

H - Friend Chains Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4460 Description For a group of people, there is an idea t

overload1997 774

2016 ICPC大连赛区 hdu5976 Detachment

Detachment Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 437    Accepted Submission(s): 144 Problem Description In a highly devel

overload1997 718
上一篇: hdu2063 过山车(二分图最大匹配基础)
下一篇: 2012杭州赛区(浙江理工大学)C - Substrings
overload1997
博客等级 码龄11年 328粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值