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

建设自己的网站免费推广app软件下载

建设自己的网站,免费推广app软件下载,网站建设 培训,建设网站加盟给定一个带整数键值的链表 L,你需要把其中绝对值重复的键值结点删掉。即对每个键值 K,只有第一个绝对值等于 K 的结点被保留。同时,所有被删除的结点须被保存在另一个链表上。例如给定 L 为 21→-15→-15→-7→15,你需要输出去重后…

给定一个带整数键值的链表 L,你需要把其中绝对值重复的键值结点删掉。即对每个键值 K,只有第一个绝对值等于 K 的结点被保留。同时,所有被删除的结点须被保存在另一个链表上。例如给定 L 为 21→-15→-15→-7→15,你需要输出去重后的链表 21→-15→-7,还有被删除的链表 -15→15。

输入格式:

输入在第一行给出 L 的第一个结点的地址和一个正整数 N(≤105,为结点总数)。一个结点的地址是非负的 5 位整数,空地址 NULL 用 -1 来表示。

随后 N 行,每行按以下格式描述一个结点:

地址 键值 下一个结点

其中地址是该结点的地址,键值是绝对值不超过104的整数,下一个结点是下个结点的地址。

输出格式:

首先输出去重后的链表,然后输出被删除的链表。每个结点占一行,按输入的格式输出。

输入样例:

00100 5
99999 -7 87654
23854 -15 00000
87654 15 -1
00000 -15 99999
00100 21 23854

输出样例:

00100 21 23854
23854 -15 99999
99999 -7 -1
00000 -15 87654
87654 15 -1

代码:

#include <iostream>
#include <unordered_map>using namespace std;const int N = 1e5 + 10;unordered_map<int, int> dedup_hash;
unordered_map<string, int>h;
string head;
int n;
struct node {string head, end;int num;
}nodes[N], dedup[N], del[N];int main() {cin  >> head >> n;for (int i = 0; i < n; i ++ ) {cin >> nodes[i].head >> nodes[i].num >> nodes[i].end;h[nodes[i].head] = i;}string l = head, r = "-1";int l_cnt = 0, r_cnt = 0;int root = h[head];while(1) {if (!dedup_hash[abs(nodes[root].num)]) {dedup_hash[abs(nodes[root].num)] = 1;if (l_cnt != 0) dedup[l_cnt - 1].end = nodes[root].head;dedup[l_cnt].head = nodes[root].head;dedup[l_cnt].num = nodes[root].num;// dedup[l_cnt].end = "-1";l_cnt ++ ;}else {if (r_cnt != 0) del[r_cnt - 1].end = nodes[root].head;del[r_cnt].head = nodes[root].head;del[r_cnt].num = nodes[root].num;r_cnt ++ ;}if (nodes[root].end == "-1") break;root = h[nodes[root].end];}for (int i = 0; i < l_cnt; i ++ ) {if (i == l_cnt - 1) cout << dedup[i].head << ' ' << dedup[i].num << ' ' << "-1" << endl;else cout << dedup[i].head << ' ' << dedup[i].num << ' ' << dedup[i].end << endl;}for (int i = 0; i < r_cnt; i ++ ) {if (i == r_cnt - 1) cout << del[i].head << ' ' << del[i].num << ' ' << "-1" << endl;else cout << del[i].head << ' ' << del[i].num << ' ' << del[i].end << endl;}
}
http://www.hkea.cn/news/158088/

相关文章:

  • 建站主机 wordpress济南网站万词优化
  • 哈尔滨app开发seo自学网官网
  • 网站答辩ppt怎么做全网关键词云在哪里看
  • 网站建设 视频seo关键词词库
  • 网站应用软件设计成都网站建设技术外包
  • 用哪个软件做网站网址查询域名解析
  • 网站安全优化域名停靠浏览器
  • 我做中医培训去哪个网站找学员谷歌排名算法
  • 如何将网站让百度收录网店培训班
  • wordpress旧版页面编辑界面百度seo推广计划类型包括
  • 网站建设茶店网网站换友链平台
  • 珠海建设工程信息网站网络营销百度百科
  • 帮别人做网站推广犯法吗关键词排名网站
  • 建设通网站是政府的么高端网站定制设计
  • 玉溪做网站的公司夸克搜索网页版
  • wordpress导航主题haowseo挂机赚钱
  • 广州做家教的网站深圳网络推广招聘
  • 锐捷网络公司排名seo技术介绍
  • 新圩做网站公司拼多多代运营一般多少钱
  • 免费网站可以做cpa?短视频营销的优势
  • b2b外贸营销型网站如何做电商赚钱
  • 建设无障碍网站seo分析报告怎么写
  • 电子商务网站开发进什么科目模板自助建站
  • 威海市住房和城乡建设局官方网站北京seo营销公司
  • 开网页卡优化关键词排名工具
  • wordpress右侧文章归档东莞公司seo优化
  • 个人网站建设需求说明书免费外链生成器
  • 湖南网站建设的公司排名网页制作网站制作
  • 公司网页网站建设 ppt模板app开发公司排行榜
  • 网站开发yuanmus联合早报 即时消息