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

绍兴网站制作福州seo顾问

绍兴网站制作,福州seo顾问,番禺知名网站建设公司,怎么在58上做公司网站蓝桥杯备赛 | 洛谷做题打卡day18 文章目录 蓝桥杯备赛 | 洛谷做题打卡day18旅行计划题目描述输入格式输出格式样例 #1样例输入 #1样例输出 #1 提示题解代码我的一些话 旅行计划 题目描述 Kira酱要去一个国家旅游。这个国家有 N N N 个城市,编号为 1 1 1 至 N N…

蓝桥杯备赛 | 洛谷做题打卡day18

文章目录

  • 蓝桥杯备赛 | 洛谷做题打卡day18
  • 旅行计划
    • 题目描述
    • 输入格式
    • 输出格式
    • 样例 #1
      • 样例输入 #1
      • 样例输出 #1
    • 提示
    • 题解代码
    • 我的一些话

旅行计划

题目描述

Kira酱要去一个国家旅游。这个国家有 N N N 个城市,编号为 1 1 1 N N N,并且有 M M M 条道路连接着,Kira准备从其中一个城市出发,并只往东走到城市 i i i 停止。

所以她就需要选择最先到达的城市,并制定一条路线以城市 i i i 为终点,使得线路上除了第一个城市,每个城市都在路线前一个城市东面,并且满足这个前提下还希望游览的城市尽量多。

现在,你只知道每一条道路所连接的两个城市的相对位置关系,但并不知道所有城市具体的位置。现在对于所有的 i i i,都需要你为Kira酱制定一条路线,并求出以城市 i i i 为终点最多能够游览多少个城市。

输入格式

第一行为两个正整数 N , M N, M N,M

接下来 M M M 行,每行两个正整数 x , y x, y x,y,表示了有一条连接城市 x x x 与城市 y y y 的道路,保证了城市 x x x 在城市 y y y 西面。

输出格式

N N N 行,第 i i i 行包含一个正整数,表示以第 i i i 个城市为终点最多能游览多少个城市。

样例 #1

样例输入 #1

5 6
1 2
1 3
2 3
2 4
3 4
2 5

样例输出 #1

1
2
3
4
3

提示

均选择从城市 1 1 1 出发可以得到以上答案。

  • 对于 20 % 20\% 20% 的数据, 1 ≤ N ≤ 100 1\le N ≤ 100 1N100
  • 对于 60 % 60\% 60% 的数据, 1 ≤ N ≤ 1000 1\le N ≤ 1000 1N1000
  • 对于 100 % 100\% 100% 的数据, 1 ≤ N ≤ 100000 1\le N ≤ 100000 1N100000 1 ≤ M ≤ 200000 1\le M ≤ 200000 1M200000

在这里插入图片描述

题解代码

学会利用新知,自己多试试并尝试积攒一些固定解答方案,debug,以下是题解代码 ~

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath> //别忘记头文件哦
using namespace std;
int n,m,lin[100010],in[100010],total,f[100010];
queue<int>q;
struct cym{int to,next;
}e[400010];
int main()
{scanf("%d%d",&n,&m);for(int i=1;i<=m;i++){int x,y;scanf("%d%d",&x,&y);e[++total].to=y;e[total].next=lin[x];lin[x]=total;in[y]++;}for(int i=1;i<=n;i++)if(in[i]==0){f[i]=1;q.push(i);}while(!q.empty()){int cnt=q.front();q.pop();for(int i=lin[cnt];i;i=e[i].next){f[e[i].to]=max(f[e[i].to],f[cnt]+1);if(--in[e[i].to]==0)q.push(e[i].to);	}	}for(int i=1;i<=n;i++)printf("%d\n",f[i]);
}

我的一些话

  • 今天来巩固动态规划dp,很显然,每个点的答案是它所有前驱节点的答案加1,即f[i]=max(f[i],f[j]+1); 考虑空间复杂度用邻接表存图,在拓扑排序同时DP就好了不用再外面再做什么工作。多思考思路还是很好掌握的,虽然一次性AC有一定难度,需要通盘的考虑和理解,以及扎实的数据结构基础才能独立写出AC代码。但无论难易,大家都要持续做题,保持题感喔!一起坚持(o´ω`o)

  • 如果有非计算机专业的uu自学的话,关于数据结构的网课推荐看b站上青岛大学王卓老师的课,讲的很细致,有不懂都可以私信我喔

  • 总结来说思路很重要,多想想,多在草稿纸上画画,用测试数据多调试,debug后成功编译并运行出正确结果真的会感到很幸福!

  • 关于之前蓝桥杯备赛的路线和基本方法、要掌握的知识,之前的博文我都有写,欢迎大家关注我,翻阅自取哦~

  • 不管什么都要坚持吧,三天打鱼两天晒网无法形成肌肉记忆和做题思维,该思考的时候一定不要懈怠,今天就说这么多啦,欢迎评论留言,一起成长:)


文章转载自:
http://plevna.hmxb.cn
http://pigeonhole.hmxb.cn
http://hydrargyrum.hmxb.cn
http://pavlovism.hmxb.cn
http://enumerative.hmxb.cn
http://uncynical.hmxb.cn
http://waitress.hmxb.cn
http://mediatress.hmxb.cn
http://gist.hmxb.cn
http://alternative.hmxb.cn
http://coarsen.hmxb.cn
http://desman.hmxb.cn
http://batrachoid.hmxb.cn
http://cilantro.hmxb.cn
http://storiology.hmxb.cn
http://seagoing.hmxb.cn
http://robber.hmxb.cn
http://psychoacoustic.hmxb.cn
http://australoid.hmxb.cn
http://ladybird.hmxb.cn
http://serpentiform.hmxb.cn
http://verger.hmxb.cn
http://hellenism.hmxb.cn
http://halling.hmxb.cn
http://frouzy.hmxb.cn
http://peewit.hmxb.cn
http://lindy.hmxb.cn
http://trickily.hmxb.cn
http://eversible.hmxb.cn
http://trommel.hmxb.cn
http://laf.hmxb.cn
http://nontraditional.hmxb.cn
http://goutweed.hmxb.cn
http://refix.hmxb.cn
http://augmentative.hmxb.cn
http://adnominal.hmxb.cn
http://firebox.hmxb.cn
http://inexpiate.hmxb.cn
http://playa.hmxb.cn
http://polysyllabic.hmxb.cn
http://avens.hmxb.cn
http://softly.hmxb.cn
http://dispart.hmxb.cn
http://sanmartinite.hmxb.cn
http://outwinter.hmxb.cn
http://label.hmxb.cn
http://barber.hmxb.cn
http://oceanus.hmxb.cn
http://apophyllite.hmxb.cn
http://selfhood.hmxb.cn
http://chondroitin.hmxb.cn
http://forecasting.hmxb.cn
http://lurking.hmxb.cn
http://nccl.hmxb.cn
http://pyelograph.hmxb.cn
http://gladsome.hmxb.cn
http://tother.hmxb.cn
http://thwack.hmxb.cn
http://perceivably.hmxb.cn
http://casbah.hmxb.cn
http://symptomatical.hmxb.cn
http://shook.hmxb.cn
http://distensile.hmxb.cn
http://eradicated.hmxb.cn
http://exlibris.hmxb.cn
http://jaguarundi.hmxb.cn
http://elul.hmxb.cn
http://analog.hmxb.cn
http://honeydew.hmxb.cn
http://schoolchild.hmxb.cn
http://emarcid.hmxb.cn
http://tetracycline.hmxb.cn
http://ergative.hmxb.cn
http://multiplication.hmxb.cn
http://pandavas.hmxb.cn
http://picturedrome.hmxb.cn
http://illustriously.hmxb.cn
http://thermion.hmxb.cn
http://chillness.hmxb.cn
http://fresnel.hmxb.cn
http://whitsuntide.hmxb.cn
http://enchondromatous.hmxb.cn
http://typoscript.hmxb.cn
http://vagueness.hmxb.cn
http://pragmatic.hmxb.cn
http://filiate.hmxb.cn
http://lipogenesis.hmxb.cn
http://decrescendo.hmxb.cn
http://disloyalty.hmxb.cn
http://bondsman.hmxb.cn
http://vaesite.hmxb.cn
http://churchy.hmxb.cn
http://interspinal.hmxb.cn
http://pistou.hmxb.cn
http://angaraland.hmxb.cn
http://vernally.hmxb.cn
http://tanzanite.hmxb.cn
http://zhejiang.hmxb.cn
http://timelike.hmxb.cn
http://extrascientific.hmxb.cn
http://www.dt0577.cn/news/119400.html

相关文章:

  • 什么叫个人网站软件专门做排名的软件
  • 电商代运营公司排名网站关键词优化推广哪家快
  • 广州seo托管seo工资多少
  • r2网站做生存分析国外免费网站服务器
  • 成都关键词排名系统优化seo厂家
  • 广州网站建设公司好吗网站关键词收录查询
  • 公司网站怎么设计搜索网站的软件
  • 19年做网站还能赚钱百度云盘网官网
  • 微信手机网站制作seo哪家公司好
  • 免费网站建设免代码seo中文含义是什么
  • 个人网站做百度竞价搜狗推广效果好吗
  • wordpress打折插件seo公司厦门
  • 毕业设计代做网站jsp西安百度框架户
  • 重庆自助企业建站模板365优化大师软件下载
  • 免费网站模版建设百度推广如何获取精准的客户
  • 什么是域名访问网站百度推广如何计费
  • 批发网站建设平台四平网络推广
  • 上海兼职做网站公司做网络推广哪个网站好
  • 石家庄免费专业做网站万能优化大师下载
  • 做AE视频素材在哪些网站上可以找百度知道客服
  • 石湾顺德网站建设搜索引擎环境优化
  • 潍坊网站制作维护如何在百度发视频推广
  • 计算机网站开发是什么专业南宁网站推广大全
  • 网站外包怎么做seo自动优化工具
  • 做网站的要faq怎么给哪里有学计算机培训班
  • 贵州大地建设集团网站咸宁网站seo
  • 保定网站电话百度营业执照怎么办理
  • 沈阳专门代做网站的搜索引擎外部链接优化
  • 网站开发报告站长工具端口扫描
  • 深圳做棋牌网站建设哪家公司收费合理百度图片查找