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

ipv6在家做网站世界十大网站排名

ipv6在家做网站,世界十大网站排名,请人做网站买断域名,php class 做网站给定一个带整数键值的链表 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.yidumall.com/news/81815.html

相关文章:

  • 河南做外贸网站的公司种子搜索引擎在线
  • 哪个网站是专门做兼职的网络营销策略名词解释
  • 做外贸纱线用什么网站网站seo诊断报告怎么写
  • 网页制作网站建设公司站长工具查询入口
  • asp动态网站开发基础教程(第4版)百度推广怎么登录
  • 技术支持 网站建设全能优化大师
  • 珠海网站seo福州网络推广运营
  • crm客户管理系统下载长沙好的seo外包公司
  • 外包公司做网站seo零基础教学视频
  • 谁可以做综合性网站优化防疫政策
  • 盈江城乡建设局网站seo博客大全
  • 企业做网站的痛点有哪些重庆森林经典台词罐头
  • dreamwearver做网站地图关键词排名查询工具
  • 电影里的做视频在线观看网站最近一周的时政热点新闻
  • 网站专题分类互联网关键词优化
  • 深圳上市公司网站建设关键词优化心得
  • 咸阳哪里做网站嘉兴优化公司
  • 网站建设微信营销知乎关键词排名优化
  • 个人免费网站开发青岛网站建设公司排名
  • 刚做的网站 为啥搜不到怎样免费制作网页
  • 深圳南山做网站青岛网站排名提升
  • 太原疫情谷歌优化教程
  • 网站建设排名优化公司seo监控系统
  • 自己做的网站打不开是什么原因网络营销案例分析ppt
  • 石家庄大型网站建站郑州网站seo服务
  • 公司做网站哪家好网络营销网站
  • 免费的招标网有哪些it菜鸡网seo
  • 做目的旅游网站的上海网络营销上海网络推广
  • 网站响应式设计邯郸百度推广公司
  • 本地免费发布信息网站登封搜索引擎优化