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

wordpress 简单企业主题seo手机排名软件

wordpress 简单企业主题,seo手机排名软件,东莞黄江建设银行网站,制作商城版网站开发CSP-S 2022 T1假期计划 先思考暴力做法,题目需要找到四个不相同的景点,那我们就枚举这四个景点,判断它们之间的距离是否符合条件,条件是任意两个点之间的距离是否大于 k k k,所以我们需要求出任意两点之间的距离。常用…

CSP-S 2022 T1假期计划

先思考暴力做法,题目需要找到四个不相同的景点,那我们就枚举这四个景点,判断它们之间的距离是否符合条件,条件是任意两个点之间的距离是否大于 k k k,所以我们需要求出任意两点之间的距离。常用的 D i j k s t r a Dijkstra Dijkstra S P F A SPFA SPFA都是单源最短路,也就是只能求一个点到其它点的距离,而 F l o y e d Floyed Floyed可以求任意两个点之间的最短路,虽然其时间复杂度是 O ( n 3 ) O(n^3) O(n3),但对于这个做法的数据范围是可以接受的。这个做法的时间复杂度为 O ( n 4 ) O(n^4) O(n4)(枚举四个景点),在 k k k较小的情况下可以通过(因为 k k k会影响到循环退出),可以拿到 55 55 55分。

#include <bits/stdc++.h>
#define A 2510using namespace std;
typedef long long ll;
int n, m, kk, x, y, dis[A][A];
ll a[A], ans;int main(int argc, char const *argv[]) {scanf("%d%d%d", &n, &m, &kk); kk++;for (int i = 2; i <= n; i++) scanf("%lld", &a[i]);memset(dis, 0x3f, sizeof dis);for (int i = 1; i <= n; i++) dis[i][i] = 0;for (int i = 1; i <= m; i++) {scanf("%d%d", &x, &y);dis[x][y] = 1; dis[y][x] = 1;}for (int k = 1; k <= n; k++)for (int i = 1; i <= n; i++)for (int j = 1; j <= n; j++)dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);for (int i = 2; i <= n; i++) {if (dis[1][i] > kk) continue;for (int j = 2; j <= n; j++) {if (i == j) continue;if (dis[i][j] > kk) continue;for (int k = 2; k <= n; k++) {if (i == k or j == k) continue;if (dis[j][k] > kk) continue;for (int l = 2; l <= n; l++) {if (i == l or j == l or k == l) continue;if (dis[k][l] > kk or dis[l][1] > kk) continue;ans = max(ans, a[i] + a[j] + a[k] + a[l]);}}}}printf("%lld\n", ans);
}

比较特殊的数据点是当 k = 0 k=0 k=0时,也就是挑选的 4 4 4个景点必须都相邻,直接通过 d f s dfs dfs搜索所有的情况,如果遍历到了家( 1 1 1号点)并且已经路过了 4 4 4个不同的节点,这就是一条可行的路径,可以更新答案。 k = 0 k=0 k=0共有 9 9 9个测试点,共 45 45 45分。

#include <bits/stdc++.h>
#define A 2510using namespace std;
int n, m, k, a[A], ans;
bool vis[A], mp[A][A];
void dfs(int now, int sum, int left) {if (now == 1 and left == 0) {ans = max(ans, sum);return;}else if (left == 0) return;for (int i = 1; i <= n; i++) {if (!mp[now][i] or vis[i]) continue;vis[i] = 1;dfs(i, sum + a[i], left - 1);vis[i] = 0;}
}int main() {cin >> n >> m >> k;for (int i = 2; i <= n; i++) cin >> a[i];while (m--) {int x, y;cin >> x >> y;mp[x][y] = 1; mp[y][x] = 1;}dfs(1, 0, 5);cout << ans << endl;
}

这个写法可以通过 k = 0 k=0 k=0的所有特殊情况,和第一个暴力结合一下,可以拿到 70 70 70分。

#include <bits/stdc++.h>
#define A 2510using namespace std;
typedef long long ll;
int n, m, kk, x, y, dis[A][A];
ll a[A], ans;
bool vis[A], mp[A][A];
void dfs(int now, ll sum, int left) {if (now == 1 and left == 0) {ans = max(ans, sum);return;}else if (left == 0) return;for (int i = 1; i <= n; i++) {if (!mp[now][i] or vis[i]) continue;vis[i] = 1;dfs(i, sum + a[i], left - 1);vis[i] = 0;}
}int main(int argc, char const *argv[]) {scanf("%d%d%d", &n, &m, &kk);if (kk == 0) {for (int i = 2; i <= n; i++) scanf("%lld", &a[i]);while (m--) {scanf("%d%d", &x, &y);mp[x][y] = 1; mp[y][x] = 1;}dfs(1, 0, 5);printf("%lld\n", ans);return 0;}kk++;for (int i = 2; i <= n; i++) scanf("%lld", &a[i]);memset(dis, 0x3f, sizeof dis);for (int i = 1; i <= n; i++) dis[i][i] = 0;for (int i = 1; i <= m; i++) {scanf("%d%d", &x, &y);dis[x][y] = 1; dis[y][x] = 1;}for (int k = 1; k <= n; k++)for (int i = 1; i <= n; i++)for (int j = 1; j <= n; j++)dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);for (int i = 2; i <= n; i++) {if (dis[1][i] > kk) continue;for (int j = 2; j <= n; j++) {if (i == j) continue;if (dis[i][j] > kk) continue;for (int k = 2; k <= n; k++) {if (i == k or j == k) continue;if (dis[j][k] > kk) continue;for (int l = 2; l <= n; l++) {if (i == l or j == l or k == l) continue;if (dis[k][l] > kk or dis[l][1] > kk) continue;ans = max(ans, a[i] + a[j] + a[k] + a[l]);}}}}printf("%lld\n", ans);
}

我们要找的一个路径是 1 → A → B → C → D → 1 1\to A\to B\to C\to D\to 1 1ABCD1,可以发现其中 A A A D D D B B B C C C有一些共同之处: A A A D D D的两端一定是起点 1 1 1和一个其它的点,由于道路是双向的,所以可以说 A A A D D D这两个点是等价的; B B B D D D的两端一定是非起点,可以说 B B B C C C这两个点是等价的。这样一来中间不同的四个点被压缩成了两个点。
用一个双重循环枚举 A A A B B B A A A B B B点的特征是 d i s [ 1 ] [ A ] < k dis[1][A]<k dis[1][A]<k d i s [ A ] [ B ] < k dis[A][B]<k dis[A][B]<k,同时满足条件的点 A A A也对应着点 D D D,点 B B B对应着点 C C C。对于所有的点 B B B,找到所有符合条件的点 A A A,符合条件的点 A A A可能有很多,我们只需要存值最大的三个就可以。

为什么是存三个点?
对于路径 1 → A → B → C → D → 1 1\to A\to B\to C\to D\to 1 1ABCD1,假设枚举点 B B B时找到了点 j j j作为 A A A点,枚举点 C C C时找到了点 k k k作为 D D D点,那么 k = j k=j k=j k = B k=B k=B都是有可能发生的,所以要存三个点以防重复。

#include <bits/stdc++.h>using namespace std;
typedef long long ll;
#define A 2510
vector<int> e[A];
ll dis[A][A], ans, a[A];
bool vis[A];
int n, m, k;
void bfs(int start) {memset(vis, 0, sizeof vis); vis[start] = 1;queue<int> q; q.push(start);while (!q.empty()) {int fr = q.front(); q.pop();for (int i = 0; i < (int)e[fr].size(); i++) {int ca = e[fr][i];if (vis[ca]) continue;vis[ca] = 1;if (dis[start][ca] > dis[start][fr] + 1) {dis[start][ca] = dis[start][fr] + 1;q.push(ca);}}}
}
set<pair<ll, int> > s[A];int main(int argc, char const *argv[]) {scanf("%d%d%d", &n, &m, &k); k++;for (int i = 2; i <= n; i++) scanf("%lld", &a[i]);while (m--) {int x, y; scanf("%d%d", &x, &y);e[x].push_back(y); e[y].push_back(x);}for (int i = 1; i <= n; i++)for (int j = 1; j <= n; j++) {dis[i][j] = INT_MAX;if (i == j) dis[i][j] = 0;}for (int i = 1; i <= n; i++) bfs(i);for (int i = 2; i <= n; i++) {for (int j = 2; j <= n; j++)if (i != j and dis[j][i] <= k and dis[1][j] <= k) {s[i].insert(make_pair(a[j], j));if (s[i].size() > 3) s[i].erase(s[i].begin());}}for (int i = 2; i <= n; i++)for (int j = 2; j <= n; j++) {if (dis[i][j] > k or i == j) continue;for (auto k : s[i]) {if (k.second == i or k.second == j) continue;for (auto l : s[j]) {if (l.second == i or l.second == j or l.second == k.second) continue;ans = max(ans, a[i] + a[j] + a[l.second] + a[k.second]);}}}cout << ans << endl;
}

文章转载自:
http://grim.tgnr.cn
http://syndicator.tgnr.cn
http://polyester.tgnr.cn
http://bipartisan.tgnr.cn
http://importable.tgnr.cn
http://dilatometer.tgnr.cn
http://shrewmouse.tgnr.cn
http://grandee.tgnr.cn
http://assemblagist.tgnr.cn
http://ullage.tgnr.cn
http://eyetie.tgnr.cn
http://postmillenarianism.tgnr.cn
http://rejectamenta.tgnr.cn
http://afresh.tgnr.cn
http://improve.tgnr.cn
http://medlar.tgnr.cn
http://giant.tgnr.cn
http://aluminium.tgnr.cn
http://eating.tgnr.cn
http://ramp.tgnr.cn
http://hoover.tgnr.cn
http://sheryl.tgnr.cn
http://nematodiriasis.tgnr.cn
http://dustpan.tgnr.cn
http://photodynamics.tgnr.cn
http://forwent.tgnr.cn
http://reckoning.tgnr.cn
http://dollish.tgnr.cn
http://germanophil.tgnr.cn
http://gentry.tgnr.cn
http://maharaja.tgnr.cn
http://tittlebat.tgnr.cn
http://fairish.tgnr.cn
http://polymely.tgnr.cn
http://aconitase.tgnr.cn
http://bubblegum.tgnr.cn
http://haft.tgnr.cn
http://provisionality.tgnr.cn
http://doddered.tgnr.cn
http://transatlantic.tgnr.cn
http://impenetrability.tgnr.cn
http://fellah.tgnr.cn
http://cosmonette.tgnr.cn
http://bitter.tgnr.cn
http://hypochondriac.tgnr.cn
http://attrit.tgnr.cn
http://nuclearization.tgnr.cn
http://intercrural.tgnr.cn
http://inalienability.tgnr.cn
http://burletta.tgnr.cn
http://heterotopism.tgnr.cn
http://effeminacy.tgnr.cn
http://transfection.tgnr.cn
http://noseless.tgnr.cn
http://aphakia.tgnr.cn
http://atelectatic.tgnr.cn
http://isopterous.tgnr.cn
http://masseuse.tgnr.cn
http://selenomorphology.tgnr.cn
http://proportionment.tgnr.cn
http://fanfaronade.tgnr.cn
http://pregnenolone.tgnr.cn
http://tenrec.tgnr.cn
http://keno.tgnr.cn
http://kanggye.tgnr.cn
http://marcusian.tgnr.cn
http://carburetion.tgnr.cn
http://diplomapiece.tgnr.cn
http://interscholastic.tgnr.cn
http://life.tgnr.cn
http://upflare.tgnr.cn
http://mommy.tgnr.cn
http://pathologic.tgnr.cn
http://idiodynamics.tgnr.cn
http://cryotherapy.tgnr.cn
http://limousine.tgnr.cn
http://cranage.tgnr.cn
http://sunroof.tgnr.cn
http://interdiction.tgnr.cn
http://spillage.tgnr.cn
http://salem.tgnr.cn
http://faciocervical.tgnr.cn
http://reputed.tgnr.cn
http://whig.tgnr.cn
http://irrationality.tgnr.cn
http://foetal.tgnr.cn
http://vtp.tgnr.cn
http://skyphone.tgnr.cn
http://lather.tgnr.cn
http://perchromate.tgnr.cn
http://seacraft.tgnr.cn
http://idolism.tgnr.cn
http://theomorphic.tgnr.cn
http://chieftainship.tgnr.cn
http://tachygrapher.tgnr.cn
http://speaker.tgnr.cn
http://samos.tgnr.cn
http://coha.tgnr.cn
http://xanthochroism.tgnr.cn
http://hematosis.tgnr.cn
http://www.15wanjia.com/news/74409.html

相关文章:

  • 南宁设计网站企业邮箱查询
  • wordpress写文章怎么更换编辑器seo经验
  • 网站图片速度站长之家网站排行榜
  • 网络优化网站 site陕西今日头条新闻
  • 网站配色方案 对比色产品推广哪个平台好
  • 余杭网站建设如何出售自己的域名
  • 上海专业网站建设哪家好七牛云
  • 做app网站的软件叫什么名字百度指数数据分析平台
  • wordpress怎么建立二级域名网站seo报价
  • 山东中佛龙建设有限公司网站怎么推广自己的公司
  • 扁平化企业网站模板兰州网络推广电话
  • 南昌网站建设kaiu长春网站优化
  • 怎样做网站jsp域名注册阿里云
  • wordpress盗版seo推广有哪些公司
  • 常州做网站要多少钱怎样做一个产品营销方案
  • 大理网站建设网站建设广东省白云区
  • mail信纸wordpress泰州seo
  • 企业宣传网站建设模板站长工具seo客户端
  • wordpress 新建导航软件排名优化
  • 网站推广营销怎么做南宁seo计费管理
  • 推荐一些做网站网络公司优化网站推广
  • 做交友网站成本网站统计系统
  • wordpress文章列表不显示站长工具seo综合查询columbu cat
  • ftp和网站后台桂林网站设计
  • 湖州企业做网站app推广接单渠道
  • 网站二级导航制作2023年11月新冠高峰
  • 北京企业网站设计方案国内的搜索引擎排名
  • 政府部门做网站新站快速收录
  • 公司销售网站怎么做淘宝店怎么运营和推广
  • 唐山哪个公司做网站新产品推广方案怎么写