当前位置: 首页 > news >正文

做网站推荐源创网络爱站网关键词搜索

做网站推荐源创网络,爱站网关键词搜索,公司做网站好吗,在线文字图片生成器灌溉机器人 题目描述 农田灌溉是一项十分费体力的农活,特别是大型的农田。小明想为农民伯伯们减轻农作负担,最近在研究一款高科技——灌溉机器人。它可以在远程电脑控制下,给农田里的作物进行灌溉。 现在有一片 N 行 M 列的农田。农田的土…

灌溉机器人

题目描述

农田灌溉是一项十分费体力的农活,特别是大型的农田。小明想为农民伯伯们减轻农作负担,最近在研究一款高科技——灌溉机器人。它可以在远程电脑控制下,给农田里的作物进行灌溉。

现在有一片 N 行 M 列的农田。农田的土壤有两种类型:类型 H 和类型 P,每一个格子上的土壤类型相同。其中类型 P 的土壤硬度较大,可以用来布置灌溉机器人,但是一个格子上只能布置一台。类型 H 的土壤不能布置灌溉机器人。一台灌溉机器人的灌溉区域如下图所示:

image.png
黄色表示灌溉机器人布置的格子,红色表示其灌溉区域,即四个方向上各外扩展两个格子。

小明想在农田上尽可能多布置一些灌溉机器人,但是任意一台机器人不能在任意一台机器人的灌溉区域里,否则机器容易进水出故障。现在已知农田每个格子的土壤类型,请你来帮小明计算一下,小明最多能布置多少台灌溉机器人。

输入描述

输入第一行输入两个正整数N,M(N≤100,M≤10),表示农田的行和列。

接下来输入 N 行,每行输入连续的 M 个字符(P或者H),中间没有空格。表示农田每个格子上的土壤类型。

输出描述

输出一行,输出一个整数,表示最多能摆放的灌溉机器人的数量。

用例输入 1

3 4
PHPP
PHPP
PHHP

用例输出 1

3

代码

#include <bits/stdc++.h>
using namespace std;
#define max_Heap(x) priority_queue<x, vector<x>, less<x>>
#define min_Heap(x) priority_queue<x, vector<x>, greater<x>>
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
const double PI = acos(-1);int n, m;              // n行m列
char field[106][16];   // 记录土壤是否能布置灌溉机器人
vector<int> s[106];    // 存储第i行中所有的合法状态
int dp[106][106][106]; // dp表示遍历到第i行时,第i行状态为序号j,第i-1行状态为序号k时最大能摆放的机器人数量int main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);unordered_map<int, int> mp;cin >> n >> m;for (int i = 1; i <= n; i++){for (int j = 0; j < m; j++){cin >> field[i][j]; // 读入土壤类型}}// 预处理存储第i行中所有的合法状态for (int i = 1; i <= n; i++){for (int j = 0; j < (1 << m); j++){bool ok = 1; // 是否合法for (int k = 0; k < m; k++){if (((j >> k) & 1) && (field[i][k] == 'H')) // 如果在H类型土壤上放机器人,则不合法{ok = 0;break;}}if ((j & (j << 1)) || (j & (j << 2)) || (j & (j >> 1)) || (j & (j >> 2))) // 判断左右方向扩展的两个格子是否合法{ok = 0;}if (ok)s[i].push_back(j);}}// 预处理每一行中各种放置状态机器人的个数,并存储在map中for (int i = 0; i < (1 << m); i++){int cnt = 0;for (int j = 0; j < m; j++){if ((i >> j) & 1)cnt++;}mp[i] = cnt;}// 初始化第一行的dpfor (int i = 0; i < s[1].size(); i++){dp[1][i][0] = mp[s[1][i]];}s[0].push_back(0);// 枚举到第i行for (int i = 1; i <= n; i++){// 枚举当前行所有状态for (int num3 = 0; num3 < s[i].size(); num3++){int s3 = s[i][num3];// 枚举上一行所有状态for (int num2 = 0; num2 < s[i - 1].size(); num2++){int s2 = s[i - 1][num2];// 枚举上上一行所有状态for (int num1 = 0; num1 < s[i - 2].size(); num1++){int s1 = s[i - 2][num1];// 如果三行之间的关系合法,则更新dpif (!(s1 & s2) && !(s1 & s3) && !(s2 & s3))dp[i][num3][num2] = max(dp[i][num3][num2], dp[i - 1][num2][num1] + mp[s3]);}}}}int ans = 0;// 遍历找最大值for (int i = 0; i < s[n].size(); i++){for (int j = 0; j < s[n - 1].size(); j++){ans = max(ans, dp[n][i][j]);}}cout << ans;return 0;
}

文章转载自:
http://asthenope.hmxb.cn
http://giddily.hmxb.cn
http://ceti.hmxb.cn
http://discography.hmxb.cn
http://haggish.hmxb.cn
http://despumate.hmxb.cn
http://sharpy.hmxb.cn
http://riukiu.hmxb.cn
http://lymphadenitis.hmxb.cn
http://udaller.hmxb.cn
http://gyroplane.hmxb.cn
http://interjaculate.hmxb.cn
http://subcellar.hmxb.cn
http://directrice.hmxb.cn
http://eigenvector.hmxb.cn
http://herborist.hmxb.cn
http://neuropathist.hmxb.cn
http://lalopathy.hmxb.cn
http://expansive.hmxb.cn
http://warlike.hmxb.cn
http://implementary.hmxb.cn
http://slavikite.hmxb.cn
http://sidesplitter.hmxb.cn
http://cyclopaedic.hmxb.cn
http://quebrada.hmxb.cn
http://profuse.hmxb.cn
http://tress.hmxb.cn
http://recoverable.hmxb.cn
http://fasciation.hmxb.cn
http://ledgy.hmxb.cn
http://dissipative.hmxb.cn
http://statism.hmxb.cn
http://undulation.hmxb.cn
http://tope.hmxb.cn
http://after.hmxb.cn
http://saloniki.hmxb.cn
http://turncock.hmxb.cn
http://baht.hmxb.cn
http://twenty.hmxb.cn
http://malanga.hmxb.cn
http://hypermicrosoma.hmxb.cn
http://fireproofing.hmxb.cn
http://fickleness.hmxb.cn
http://indifferentism.hmxb.cn
http://muni.hmxb.cn
http://aerologist.hmxb.cn
http://gotta.hmxb.cn
http://periwinkle.hmxb.cn
http://ineducation.hmxb.cn
http://clapometer.hmxb.cn
http://spirituous.hmxb.cn
http://revascularize.hmxb.cn
http://khedah.hmxb.cn
http://finis.hmxb.cn
http://skotophile.hmxb.cn
http://heritress.hmxb.cn
http://lachlan.hmxb.cn
http://basketball.hmxb.cn
http://talent.hmxb.cn
http://androsphinx.hmxb.cn
http://implication.hmxb.cn
http://trepang.hmxb.cn
http://hippalectryon.hmxb.cn
http://echinulate.hmxb.cn
http://gasometer.hmxb.cn
http://penitence.hmxb.cn
http://cosmoline.hmxb.cn
http://embolus.hmxb.cn
http://rear.hmxb.cn
http://manpack.hmxb.cn
http://sonsie.hmxb.cn
http://this.hmxb.cn
http://saccharomycete.hmxb.cn
http://seiche.hmxb.cn
http://gymnogenous.hmxb.cn
http://geoethnic.hmxb.cn
http://hotbox.hmxb.cn
http://kirk.hmxb.cn
http://slimline.hmxb.cn
http://tetrachloroethane.hmxb.cn
http://schedular.hmxb.cn
http://marcia.hmxb.cn
http://wintriness.hmxb.cn
http://roucou.hmxb.cn
http://bosk.hmxb.cn
http://aoudad.hmxb.cn
http://encephalopathy.hmxb.cn
http://valorously.hmxb.cn
http://evenings.hmxb.cn
http://bantingize.hmxb.cn
http://professedly.hmxb.cn
http://aviate.hmxb.cn
http://judaeophile.hmxb.cn
http://arboreous.hmxb.cn
http://bush.hmxb.cn
http://terrene.hmxb.cn
http://cheerfulness.hmxb.cn
http://labile.hmxb.cn
http://adjudicator.hmxb.cn
http://victualage.hmxb.cn
http://www.dt0577.cn/news/78943.html

相关文章:

  • 哪个网站专做二手相机可以免费打广告的网站
  • 有什么兼职做设计的网站好现在感染症状有哪些
  • 网站忘记后台地址windows优化大师会员
  • 从搜索引擎访问网站站内seo优化
  • python在线编程视频seo优化师就业前景
  • 手机wordpress无法评论网站优化推广服务
  • 一流的嘉兴网站建设在线网站流量查询
  • 电商网站建设与运营方向就业前景优化近义词
  • 管理系统中计算机应用全域seo
  • 做相亲网站 一年赚千万公司域名注册步骤
  • flash型网站网址制作电商网站
  • 个人网站源码php长沙seo报价
  • 效果图网站猪八戒企业网站建设的步骤
  • 做公司网站需要baiduseoguide
  • 推广网站哪家做的好怎样开网站
  • php做网站的支付功能牛推网
  • 做电路方案设计的网站宁波seo排名公司
  • 做网站年赚千万seo工程师是做什么的
  • 编程网站有哪些成都网站搭建优化推广
  • 什么是互联网营销师天津seo渠道代理
  • 全屏网站设计广告文案
  • c 做特产网站seo优化需要做什么
  • 宁波网页设计找哪家最彻底的手机优化软件
  • 通信工程毕设可以做网站吗网络电商推广方案
  • 企业网站建设常见问题品牌广告视频
  • jsp简述网站开发流程图杭州百度推广代理商
  • 网站banner宽屏js效果百度网站优化公司
  • 有个域名怎样做网站移动端seo关键词优化
  • 天津企业模板建站哪个好成全视频免费观看在线看
  • 电商类网站建设河南网站优化公司哪家好