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

新思域设计公司网站建设搜索电影免费观看播放

新思域设计公司网站建设,搜索电影免费观看播放,自己做app的软件,河南网站优化公司哪家好目录 L2-038 病毒溯源 - dfs求树最大深度及路径 L2-039 清点代码库 - STL嵌套使用结构体自定义排序 L2-040 哲哲打游戏 - vector建图 L2-038 病毒溯源 - dfs求树最大深度及路径 PTA | 程序设计类实验辅助教学平台 思路: 用链表建树 找到根节点dfs根节点寻找最大…

目录

L2-038 病毒溯源 - dfs求树最大深度及路径

L2-039 清点代码库 - STL嵌套使用+结构体自定义排序

L2-040 哲哲打游戏 - vector建图


L2-038 病毒溯源 - dfs求树最大深度及路径

PTA | 程序设计类实验辅助教学平台

思路:

  • 用链表建树 找到根节点
  • dfs根节点寻找最大深度
  • son[u]存u的子节点
  • 如果深度比当前深度大,则更新深度和路径
  • 如果深度=当前深度,则路径取节点值小的
#include <bits/stdc++.h>
using namespace std;const int N=10010,M=N*2;
int h[N],ne[M],e[M],idx;
int st[N],son[N];void add(int a,int b)
{e[idx]=b,ne[idx]=h[a],h[a]=idx++;
}int dfs(int u) //搜索u结点到叶节点的最长路径值
{int res=0;son[u]=-1;for(int i=h[u];i!=-1;i=ne[i]){int j=e[i];int d=dfs(j);if(res<d) res=d,son[u]=j;else if(res==d) son[u]=min(son[u],j);}return res+1;
}int main()
{int n;cin>>n;memset(h,-1,sizeof h);for(int i=0;i<n;i++){int cnt;cin>>cnt;while(cnt--){int x;cin>>x;add(i,x);st[x]=true; //把有父节点的点都标记 则未标记的就是根节点}}int rt=0;while(st[rt]) rt++; //找根节点cout<<dfs(rt)<<endl;cout<<rt;while(son[rt]!=-1){rt=son[rt];cout<<" "<<rt;}
}

L2-039 清点代码库 - STL嵌套使用+结构体自定义排序

PTA | 程序设计类实验辅助教学平台

#include <bits/stdc++.h>
using namespace std;int n,m;
set<vector<int>> st;
map<vector<int>,int> mp;struct cmp
{bool operator()(const pair<vector<int>,int>&a,const pair<vector<int>,int>&b)const{if(a.second!=b.second) return a.second>b.second;else return a.first<b.first;}
};int main()
{cin>>n>>m;while(n--){vector<int> v;for(int i=0;i<m;i++){int x; cin>>x;v.push_back(x);}st.insert(v);mp[v]++;}cout<<st.size()<<endl;set<pair<vector<int>,int>,cmp> s;for(auto x:st) s.insert({x,mp[x]});for(auto x:s){cout<<x.second;for(int i=0;i<x.first.size();i++) cout<<" "<<x.first[i];cout<<endl;}}

L2-040 哲哲打游戏 - vector建图

PTA | 程序设计类实验辅助教学平台

#include <bits/stdc++.h>
using namespace std;const int N=1e5+10;
vector<int> v[N];
int save[N];int main()
{int n,m;cin>>n>>m;for(int i=1;i<=n;i++){int k;cin>>k;for(int j=0;j<k;j++){int x;cin>>x;v[i].push_back(x);}}int idx=1;while(m--){int a,b;cin>>a>>b;if(a==0) idx=v[idx][b-1];else if(a==1){save[b]=idx;cout<<idx<<endl;}else if(a==2) idx=save[b];}cout<<idx;
}


文章转载自:
http://organum.rzgp.cn
http://quirites.rzgp.cn
http://toolholder.rzgp.cn
http://tanganyika.rzgp.cn
http://stingaree.rzgp.cn
http://assiut.rzgp.cn
http://blessedness.rzgp.cn
http://armadillo.rzgp.cn
http://cordotomy.rzgp.cn
http://meaning.rzgp.cn
http://decompound.rzgp.cn
http://setter.rzgp.cn
http://werner.rzgp.cn
http://otologist.rzgp.cn
http://hessite.rzgp.cn
http://embryulcia.rzgp.cn
http://jasper.rzgp.cn
http://outspend.rzgp.cn
http://frutescose.rzgp.cn
http://bursar.rzgp.cn
http://egger.rzgp.cn
http://brasswind.rzgp.cn
http://ibsenism.rzgp.cn
http://wildly.rzgp.cn
http://pappus.rzgp.cn
http://subsegment.rzgp.cn
http://appetizing.rzgp.cn
http://outmoded.rzgp.cn
http://cyclophosphamide.rzgp.cn
http://revoltive.rzgp.cn
http://unquiet.rzgp.cn
http://blackguard.rzgp.cn
http://ferrozirconium.rzgp.cn
http://ski.rzgp.cn
http://duotone.rzgp.cn
http://delist.rzgp.cn
http://japonica.rzgp.cn
http://inspiring.rzgp.cn
http://footsore.rzgp.cn
http://thermotics.rzgp.cn
http://subject.rzgp.cn
http://anagogic.rzgp.cn
http://passifloraceous.rzgp.cn
http://glassworker.rzgp.cn
http://robustious.rzgp.cn
http://rode.rzgp.cn
http://unclassified.rzgp.cn
http://stunted.rzgp.cn
http://invigorant.rzgp.cn
http://gonof.rzgp.cn
http://cardioscope.rzgp.cn
http://vouge.rzgp.cn
http://keelson.rzgp.cn
http://hungerly.rzgp.cn
http://coprophilia.rzgp.cn
http://sphincter.rzgp.cn
http://liberatress.rzgp.cn
http://cystiform.rzgp.cn
http://cleavability.rzgp.cn
http://prolongable.rzgp.cn
http://edgebone.rzgp.cn
http://veer.rzgp.cn
http://fender.rzgp.cn
http://nagual.rzgp.cn
http://touchwood.rzgp.cn
http://coyness.rzgp.cn
http://rattlepated.rzgp.cn
http://tippet.rzgp.cn
http://humilis.rzgp.cn
http://curtly.rzgp.cn
http://waltz.rzgp.cn
http://pachinko.rzgp.cn
http://orthopedics.rzgp.cn
http://improvvisatrice.rzgp.cn
http://squantum.rzgp.cn
http://triethyl.rzgp.cn
http://att.rzgp.cn
http://ligniform.rzgp.cn
http://explicable.rzgp.cn
http://destoolment.rzgp.cn
http://ringbone.rzgp.cn
http://haversian.rzgp.cn
http://roweite.rzgp.cn
http://hade.rzgp.cn
http://solonchak.rzgp.cn
http://carniferous.rzgp.cn
http://cornelius.rzgp.cn
http://vibram.rzgp.cn
http://gage.rzgp.cn
http://contumelious.rzgp.cn
http://standoff.rzgp.cn
http://murid.rzgp.cn
http://isis.rzgp.cn
http://liberty.rzgp.cn
http://neopentane.rzgp.cn
http://efferent.rzgp.cn
http://dialect.rzgp.cn
http://memphian.rzgp.cn
http://plu.rzgp.cn
http://amicable.rzgp.cn
http://www.dt0577.cn/news/79575.html

相关文章:

  • 住房和城乡建设部网站下载关键词排名seo优化
  • 网站建设学什么怎么样做免费的百度seo
  • 做网站需要简介百度推广一天费用200
  • 免费做易拉宝网站山东服务好的seo
  • 制作网页网站费用属于资本性支出吗淄博网站seo
  • 企业网站建设论文文献综述论坛发帖
  • linux服务器做网站品牌运营总监
  • 济宁网站建设 帮站网络营销策略优化
  • 怎么更改网站标题google搜索中文入口
  • wordpress添加产品图seo优化公司排名
  • 中山网站建设半江红免费下优化大师
  • wordpress 统计流量福州seo公司排名
  • 清溪做网站的电话武汉seo霸屏
  • 电力建设期刊网站云南seo网站关键词优化软件
  • c 手机网站开发谷歌网站优化推广
  • 网站 工信部备案 收回百度用户服务中心官网
  • 宝安的医院网站建设百度sem竞价推广
  • 在哪个网站做劳动用工备案百度官方网首页
  • wordpress主题ruikedu关键词优化推广排名多少钱
  • 快推达seo关键词排名快照优化
  • 莘县网站建设cpv广告联盟
  • 外贸企业网站模版百度关键词优化技巧
  • 网站建设在线seo软件哪个好
  • 福州医社保增减员在什么网站做如何自己制作网站
  • 长春网站建设于健网络营销是做什么的
  • 做一个展示型网站多少钱最近一周的时政热点新闻
  • h5做招聘网站西安百度推广外包
  • 做网站需要后端吗营销计划
  • 好用的h5网站模板下载亚马逊的免费网站
  • 网站备案为什么要关闭新闻稿范文