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

如何制作网站连接数据库重庆市建设工程信息网查询人员

如何制作网站连接数据库,重庆市建设工程信息网查询人员,做公众号网站有哪些,如何开网店做电商题意#xff1a; 给定前序遍历和中序遍历#xff0c;问u和v的lca #xff08;先是中序#xff0c;后是中序#xff09; 题解#xff1a; 方法一#xff1a; 参考题解 将树映射到一颗BST上#xff0c;在BST上找到答案然后再映射回原本的树 方法二#xff1a; 参考题…题意 给定前序遍历和中序遍历问u和v的lca 先是中序后是中序 题解 方法一 参考题解 将树映射到一颗BST上在BST上找到答案然后再映射回原本的树 方法二 参考题解 已知某个树的根结点若a和b在根结点的左边则a和b的最近公共祖先在当前子树根结点的左子树寻找如果a和b在当前子树根结点的两边在当前子树的根结点就是a和b的最近公共祖先如果a和b在当前子树根结点的右边则a和b的最近公共祖先就在当前子树的右子树寻找。中序加先序可以唯一确定一棵树在不构建树的情况下在每一层的递归中可以得到树的根结点在此时并入lca算法可以确定两个结点的公共祖先 代码 #include iostream #include vector #include set #include cstring #include cstdio #include mapusing namespace std;int m, n; int opre[10009], oin[10009]; int pre[10009], in[10009]; mapint, int otos, stoo;int main() {cin m n;for (int i 0; i n; i){cin oin[i];otos[oin[i]] i;stoo[i] oin[i];}for (int i 0; i n; i){cin opre[i];pre[i] otos[opre[i]];}for (int i 0; i m; i){int u, v;int a;bool flag1 true, flag2 true;cin u v;if (otos.find(u) otos.end())flag1 false;if (otos.find(v) otos.end())flag2 false;if (!flag1 || !flag2){if (!flag1 !flag2)printf(ERROR: %d and %d are not found.\n, u, v);elseprintf(ERROR: %d is not found.\n, flag1 false ? u : v);continue;}u otos[u];v otos[v];for (int j 0; j n; j){a pre[j];if (a u a v || a u a v || a u || a v)break;}u stoo[u];v stoo[v];a stoo[a];if (a u || a v)printf(%d is an ancestor of %d.\n, a, a u ? v : u);elseprintf(LCA of %d and %d is %d.\n, u, v, a);}return 0; }#include iostream #include vector #include map using namespace std; mapint, int pos; vectorint in, pre; void lca(int inl, int inr, int preRoot, int a, int b) {if (inl inr) return;int inRoot pos[pre[preRoot]], aIn pos[a], bIn pos[b];if (aIn inRoot bIn inRoot)lca(inl, inRoot-1, preRoot1, a, b);else if ((aIn inRoot bIn inRoot) || (aIn inRoot bIn inRoot))printf(LCA of %d and %d is %d.\n, a, b, in[inRoot]);else if (aIn inRoot bIn inRoot)lca(inRoot1, inr, preRoot1(inRoot-inl), a, b);else if (aIn inRoot)printf(%d is an ancestor of %d.\n, a, b);else if (bIn inRoot)printf(%d is an ancestor of %d.\n, b, a); } int main() {int m, n, a, b;scanf(%d %d, m, n);in.resize(n 1), pre.resize(n 1);for (int i 1; i n; i) {scanf(%d, in[i]);pos[in[i]] i;}for (int i 1; i n; i) scanf(%d, pre[i]);for (int i 0; i m; i) {scanf(%d %d, a, b);if (pos[a] 0 pos[b] 0)printf(ERROR: %d and %d are not found.\n, a, b);else if (pos[a] 0 || pos[b] 0)printf(ERROR: %d is not found.\n, pos[a] 0 ? a : b);elselca(1, n, 1, a, b);}return 0; }
http://www.pierceye.com/news/415818/

相关文章:

  • 免费网站制作中小型企业查询网址
  • 企业网站的seo广州市企业网站建设平台
  • 备案网站名称与实际网站名称不一致企业门户网站平台建设招标采购文件
  • 张掖网站制作wordpress 主题安装教程
  • 企业网站建设合作合同网页做成app
  • 郑州建网站价格医院网页
  • 南京设计网站网站速度的重要性
  • 河南智能网站建设平台简易网站建设
  • 成都鱼羊环保网站制作设计网站 关键字 标签
  • 邓修明调研成都网站建设鞍山建一个网站大概要多少钱
  • 聊城网站开发公司专业开发小程序公司
  • 三门峡网站建设推广用个人电脑做服务器建网站
  • 黄冈论坛交友网站首页seo怎么做
  • 网站注册域名 免费网站建设进度及实施过程
  • 如何购买一个网站的域名小程序开发公司网
  • 产品包装设计素材网站均安建网站
  • 甘肃建设网站找别人做网站需要注意什么
  • php做电子商城网站创业找项目
  • 网站建设建设公司有哪些帝国手机网站cms系统
  • 网站设计包括什么软件房产交易网上预约平台
  • 企业做网站有什么好处坏处四川住房城乡和城乡建设厅网站首页
  • 小学学校网站建设计划广州seo顾问服务
  • 做淘宝素材网站哪个好用网站制作网站建设需要多少钱
  • 住房建设部官方网站设计费计取wordpress仿百度搜索主题
  • 云建站平台哪家好沈阳百度seo关键词排名优化软件
  • 响应式网站设计的优点国内优秀设计网站
  • 网站开发集成环境国内html5网站欣赏
  • iis7.5 没有默认网站北京seo的排名优化
  • 两学一做网站是多少钱营销型网站策划怎么做
  • 渭南做网站的自建房设计图