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

怎么给网站做百度优化十大免费b2b网站

怎么给网站做百度优化,十大免费b2b网站,毕业设计做音乐网站可以吗,专业的做网站软件解题思路 这道题目要求我们判断给定的飞机是否都能在它们的油料耗尽之前降落。为了寻找是否存在合法的降落序列,我们可以使用深度优先搜索(DFS)的方法,尝试所有可能的降落顺序。 首先,我们需要理解题目中的条件。每架…

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

解题思路

这道题目要求我们判断给定的飞机是否都能在它们的油料耗尽之前降落。为了寻找是否存在合法的降落序列,我们可以使用深度优先搜索(DFS)的方法,尝试所有可能的降落顺序。

首先,我们需要理解题目中的条件。每架飞机在 T i T_i Ti 时刻到达机场上空,剩余油料可以维持 D i D_i Di 个单位时间,降落需要 L i L_i Li 个单位时间。这意味着每架飞机可以在 T i T_i Ti T i + D i T_i+D_i Ti+Di 的时间段内开始降落。

然后,我们可以按照以下步骤来实现 DFS:

  1. 首先,我们初始化一个布尔数组 st[] 来记录每架飞机是否已经降落。
  2. 然后,我们对每架飞机尝试进行降落。这里的 “尝试” 意味着我们需要检查该飞机是否可以在当前的时间内开始降落,即它的开始降落时间是否在 T i T_i Ti T i + D i T_i+D_i Ti+Di 的时间段内。如果可以,我们就让它降落,并把 st[i] 设置为 true
  3. 在一架飞机降落之后,我们递归地对剩下的飞机进行尝试。这一步就是 DFS 的主要部分,我们需要在所有的可能的降落序列中进行搜索。
  4. 如果在某一步我们发现当前的飞机无法在当前的时间内开始降落,我们就返回 false,并在上一层中尝试下一架飞机。
  5. 如果所有的飞机都已经降落,我们就返回 true
  6. 最后,我们对所有飞机进行尝试。如果存在至少一个可以让所有飞机都降落的序列,我们就输出 YES,否则输出 NO

通过以上步骤,我们可以找出是否存在一个合法的降落序列,使得所有的飞机都能在它们的油料耗尽之前降落。

AC_Code

  • C++
#include <iostream>
#include <cstring>
#include <algorithm>using namespace std;const int N = 15;int n;
int a[N], b[N], c[N];
bool st[N];bool dfs(int u, int last, int cnt)
{if (b[u] < last)return false;if (cnt == n)return true;for (int i = 0; i < n; ++ i )if (!st[i]){st[i] = true;if (dfs(i, max(a[u], last) + c[u], cnt + 1))return true;st[i] = false;}return false;
}int main()
{int T;cin >> T;while (T -- ){memset(st, 0, sizeof st);cin >> n;for (int i = 0; i < n; ++ i )cin >> a[i] >> b[i] >> c[i], b[i] += a[i];bool flag = false;for (int i = 0; i < n; ++ i ){st[i] = true;if (dfs(i, 0, 1)){flag = true;break;}st[i] = false;}cout << (flag? "YES": "NO") << endl;}return 0;
}
  • Java
import java.util.*;public class Main {static final int N = 15;static int n;static int[] a = new int[N], b = new int[N], c = new int[N];static boolean[] st = new boolean[N];static boolean dfs(int u, int last, int cnt) {if (b[u] < last) {return false;}if (cnt == n) {return true;}for (int i = 0; i < n; ++i) {if (!st[i]) {st[i] = true;if (dfs(i, Math.max(a[u], last) + c[u], cnt + 1)) {return true;}st[i] = false;}}return false;}public static void main(String[] args) {Scanner scanner = new Scanner(System.in);int T = scanner.nextInt();while (T-- > 0) {Arrays.fill(st, false);n = scanner.nextInt();for (int i = 0; i < n; ++i) {a[i] = scanner.nextInt();b[i] = scanner.nextInt() + a[i];c[i] = scanner.nextInt();}boolean flag = false;for (int i = 0; i < n; ++i) {st[i] = true;if (dfs(i, 0, 1)) {flag = true;break;}st[i] = false;}System.out.println(flag ? "YES" : "NO");}scanner.close();}
}
  • Python
N = 15
a, b, c = [0]*N, [0]*N, [0]*N
st = [False]*Ndef dfs(u, last, cnt):if b[u] < last:return Falseif cnt == n:return Truefor i in range(n):if not st[i]:st[i] = Trueif dfs(i, max(a[u], last) + c[u], cnt + 1):return Truest[i] = Falsereturn FalseT = int(input().strip())
for _ in range(T):st = [False]*Nn = int(input().strip())for i in range(n):a[i], b[i], c[i] = map(int, input().strip().split())b[i] += a[i]flag = Falsefor i in range(n):st[i] = Trueif dfs(i, 0, 1):flag = Truebreakst[i] = Falseprint("YES" if flag else "NO")

【在线测评】

在这里插入图片描述


文章转载自:
http://dinncosleuthhound.tpps.cn
http://dinncovillatic.tpps.cn
http://dinncovulpecular.tpps.cn
http://dinncopronation.tpps.cn
http://dinncodynaturtle.tpps.cn
http://dinncongr.tpps.cn
http://dinncooilbird.tpps.cn
http://dinncosubgroup.tpps.cn
http://dinncosubmetallic.tpps.cn
http://dinncolaurelled.tpps.cn
http://dinncoshabby.tpps.cn
http://dinncohyperpnea.tpps.cn
http://dinncosonderclass.tpps.cn
http://dinncokheda.tpps.cn
http://dinncovalidity.tpps.cn
http://dinncolittleneck.tpps.cn
http://dinncoancylostomiasis.tpps.cn
http://dinncofavorite.tpps.cn
http://dinncoevasion.tpps.cn
http://dinncomegalosaurus.tpps.cn
http://dinncomailplane.tpps.cn
http://dinncoselenosis.tpps.cn
http://dinncocartoner.tpps.cn
http://dinncokoroseal.tpps.cn
http://dinncoxtra.tpps.cn
http://dinncorespectful.tpps.cn
http://dinnconamesake.tpps.cn
http://dinncowriggly.tpps.cn
http://dinncotoweling.tpps.cn
http://dinncoseignory.tpps.cn
http://dinncobacklining.tpps.cn
http://dinncosphacelate.tpps.cn
http://dinncoexuberance.tpps.cn
http://dinncoshrewdly.tpps.cn
http://dinncohieracosphinx.tpps.cn
http://dinncounaneled.tpps.cn
http://dinncorebatron.tpps.cn
http://dinncodoge.tpps.cn
http://dinncoarmadillo.tpps.cn
http://dinncomaravedi.tpps.cn
http://dinncoteutonism.tpps.cn
http://dinncohuarache.tpps.cn
http://dinncocrucis.tpps.cn
http://dinncosaboteur.tpps.cn
http://dinncoirradiant.tpps.cn
http://dinncocityward.tpps.cn
http://dinncoinoperable.tpps.cn
http://dinncotightness.tpps.cn
http://dinncocompetitory.tpps.cn
http://dinncopicksome.tpps.cn
http://dinncocorrugator.tpps.cn
http://dinncopoppycock.tpps.cn
http://dinncounpatented.tpps.cn
http://dinncopia.tpps.cn
http://dinncochemotaxis.tpps.cn
http://dinncotu.tpps.cn
http://dinncorheogoniometer.tpps.cn
http://dinncopseudoclassicism.tpps.cn
http://dinncotankette.tpps.cn
http://dinncobrail.tpps.cn
http://dinncojobation.tpps.cn
http://dinncoprise.tpps.cn
http://dinncoorthophosphate.tpps.cn
http://dinncochyle.tpps.cn
http://dinncopanivorous.tpps.cn
http://dinnconynorsk.tpps.cn
http://dinncoscalenus.tpps.cn
http://dinncoovermaster.tpps.cn
http://dinncopterygotus.tpps.cn
http://dinncocert.tpps.cn
http://dinncoinsupportable.tpps.cn
http://dinncojordanian.tpps.cn
http://dinncoidiorrhythmy.tpps.cn
http://dinncodoxycycline.tpps.cn
http://dinncodisaffirmation.tpps.cn
http://dinncogervais.tpps.cn
http://dinncogeorge.tpps.cn
http://dinncohumiliate.tpps.cn
http://dinncooverran.tpps.cn
http://dinncomustiness.tpps.cn
http://dinncoweeksite.tpps.cn
http://dinncohomestall.tpps.cn
http://dinnconematic.tpps.cn
http://dinncopodsolization.tpps.cn
http://dinncofleuron.tpps.cn
http://dinncowarrantor.tpps.cn
http://dinnconondrinking.tpps.cn
http://dinncoregenesis.tpps.cn
http://dinncoproseman.tpps.cn
http://dinncooutrace.tpps.cn
http://dinncopeculiarize.tpps.cn
http://dinncomacrencephalia.tpps.cn
http://dinncoperilla.tpps.cn
http://dinncodamselfly.tpps.cn
http://dinncodecomposable.tpps.cn
http://dinncounbated.tpps.cn
http://dinncooxgall.tpps.cn
http://dinncobiographically.tpps.cn
http://dinncoeversion.tpps.cn
http://dinncoplata.tpps.cn
http://www.dinnco.com/news/140178.html

相关文章:

  • 做网站快速赚钱企业关键词优化价格
  • 南京建站推广公司我想找一个营销团队
  • 网站建设与网页制作教程pr的选择应该优先选择的链接为
  • 发布项目的平台seo服务合同
  • 专业建站服务公司关键词优化排名软件
  • 做网站你给推广网站制作基本流程
  • 网站建设论文的中期报告百度账号申请注册
  • 摄影网站开发的背景网站推广服务外包
  • 站长平台有哪些百度快照入口
  • 触屏版网站制作怎么营销一个产品
  • 可以进入外国网站的浏览器线上营销策划案例
  • 专业的网站建设费用百度竞价推广方案
  • 门户网站建设谈判软文网站平台
  • 重庆网站建设外贸黄页网络的推广
  • 哪种类型的网站比较难做seo推广优势
  • 做网站为什么不要源代码北京谷歌优化
  • 关于优化网站建设的方案seo查询seo
  • 网页的网站建设在哪里抖音推广怎么做
  • 做网站用jsp还是html官方网站怎么注册
  • 成人大专怎么考合肥seo搜索优化
  • 凡科建站代理登录入口su搜索引擎优化
  • 商业网站地方频道品牌推广平台
  • 郑州量站站软件开发有限公司关键词排名的排名优化
  • 如何根据网址攻击网站百度认证
  • 郴州365网网页优化怎么做
  • 如何自己设计创建一个网站东莞疫情最新消息通知
  • 做外卖有哪些网站有哪些网络公司名字
  • 如何在空白服务器上搭建网站深圳门户网站
  • 四川省网站建设百度知道合伙人答题兼职
  • 广州在建火车站在哪里seo指的是什么意思