1097 Deduplication on a Linked List (25 point(s))

整流桥选型参数,结构原理,工艺与注意问题总结 整流桥(Rectifier Bridge)是一种电子元件,它的主要作用是将交流电(AC)转换为直流电(DC)。这种转换在许多电子设备中都是必要的,因为大多数电子元件和电路都需要直流电源来工作。本文对整流桥的工作原理,结构特点,工艺流程,选型参数及设计注意事项进行总结。 阅读详情

1097 Deduplication on a Linked List (25 point(s))

Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or absolute value of its key equals K will be kept. At the mean time, all the removed nodes must be kept in a separate list. For example, given L being 21→-15→-15→-7→15, you must output 21→-15→-7, and the removed list -15→15.

Input Specification:

Each input file contains one test case. For each case, the first line contains the address of the first node, and a positive N (≤10​5​​) which is the total number of nodes. The address of a node is a 5-digit nonnegative integer, and NULL is represented by −1.

Then N lines follow, each describes a node in the format:

Address Key Next

where Address is the position of the node, Key is an integer of which absolute value is no more than 10​4​​, and Next is the position of the next node.

Output Specification:

For each case, output the resulting linked list first, then the removed list. Each node occupies a line, and is printed in the same format as in the input.

Sample Input:

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

Sample Output:

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

链表、STL(set/vector)的使用。

思路:

set<int> s记录已经在链表中的元素的绝对值,v和u分别记录在链表中的和不在链表中的元素的地址。根据给出的头结点地址,遍历整个链表,如果该地址的元素的绝对值还不在s中,说明在v中,否则在u中。

然后根据得到的v和u按照格式输出。

注意点:u也是需要输出的,认真读题很重要。

#include<iostream>
#include<set>
#include<vector>
#include<cstring>
#include<cmath>
using namespace std;
const int MAX = 1e5+7;
int data[MAX];
int nextAdd[MAX];
int main(void){
	int N,root;cin>>root>>N;
	int address,key,next;
	for(int i=0;i<N;i++){
		cin>>address>>key>>next;
		data[address]=key;
		nextAdd[address]=next;
	}
	set<int> s;
	vector<int> v;
	vector<int> u;
	while(root!=-1){
		if(s.find(abs(data[root]))==s.end()){
			v.push_back(root);
			s.insert(abs(data[root]));
		}
		else{
			u.push_back(root);
		}
		root = nextAdd[root];
	}
	for(int i=0;i<v.size();i++){
		if(i!=v.size()-1)printf("%05d %d %05d\n",v[i],data[v[i]],v[i+1]);
		else printf("%05d %d -1\n",v[i],data[v[i]]);
	}
	for(int i=0;i<u.size();i++){
		if(i!=u.size()-1)printf("%05d %d %05d\n",u[i],data[u[i]],u[i+1]);
		else printf("%05d %d -1\n",u[i],data[u[i]]);
	}
	return 0;
} 

 

python实现边缘检测Canny算子 (附完整源码) 阅读详情

相关推荐

playwright-mcp 安装使用的详细教程

Playwright MCP 快速入门指南 Playwright MCP Server 是由微软开发的浏览器自动化服务,通过 MCP 协议为 AI/Agent/LLM 提供网页交互能力。它基于可访问性树而非屏幕截图,支持多种浏览器和运行模式。 安装要求: Node.js v18+ 命令行操作能力 支持 MCP 的客户端 安装方式: 通过 npx 快速启动:npx @playwright/mcp@latest 项目依赖安装:npm install @playwright/mcp 主要特性: 支持 Chrome

上善若水 8008

1097 Deduplication on a Linked List(25分)

先存到结构体数组中,输入的同时map<int, bool> 记录该值是否已经存在(首次出现的记为0,其余记为1);然后构建链表,从头到尾遍历即可。给定一个带权重的链表A,从头至尾遍历排除A中权重的绝对值等于之前已经出现过的结点,整合到B中,然后分别输出A,B。

a131529的博客 241

Silvaco Atlas入门指南——从零开始掌握半导体器件仿真

本文为Silvaco Atlas半导体器件仿真软件的入门指南,详细介绍了从零开始掌握该工具的核心流程。内容涵盖Atlas的基本概念、仿真流程、核心文件(输入、结构、输出文件)、交互式与批处理两种操作模式,并逐步演示了如何从定义网格、划分区域、设置电极到进行掺杂、选择物理模型并求解,最终获取和分析器件特性的完整步骤。旨在帮助微电子相关专业人员和工程师快速上手这一强大的“数字实验室”,提升半导体器件设计与研发效率。

weixin_29306317的博客 402

【PAT-A1097】 Deduplication on a Linked List(静态链表)

【题意】 给出一个静态链表,将所有相同绝对值的结点的重复结点按顺序从原链表剔除,被剔除的结点按顺序再组成一条链表,依次输出去重后的链表和重复结点组成的链表。 【思路】 先按照输入创建初始链表 再次遍历链表,同时对首次出现的绝对值结点的hash值置为true。并重新设置其next,这个设置需要得到该链表末尾的结点地址,所以可以用一个变量记录一下。 hash值为true的绝对值的结点为重复结点。和非...

Honcy Ye 420

CXL ALMP(ARB/MUX Link Management Packet)理解

ALMP(ARB/MUX Link Management Packet) 是CXL协议中由ARB/MUX层生成和处理的专用管理报文,用于协调链路电源状态切换(如L0s/L1)和虚拟链路状态机(vLSM)同步。ALMP是ARB/MUX层的控制平面报文,专用于以下场景:协调多协议(CXL.io、CXL.cachemem等)的链路状态切换(如L1进入/退出)。维护各协议独立的虚拟链路状态机(vLSM) 状态同步。在物理层(PHY)与链路层(Link Layer)之间仲裁电源管理请求。

Summer的博客 1200

Matlab使用GitHub的踩坑记录(持续更新)

Matlab使用git的踩坑记录前言Matlab设置Git的官方帮助文档系统配置新建Git两种代码管理方式典型源代码管理SVN分布式源代码管理 Git注意:SVN和Git都可以用GitHub创建新的库 前言 作为Git初学者,对Git的代码版本管理非常非常喜欢,给了我极大的安全感。特别是想到之前的几次Matlab、Latex和python的代码莫名其妙被折腾没了又没法找回的悲剧,决定慢慢的走入gi...

voluntry的博客 7298

PAT甲级 1097 Deduplication on a Linked List(25)

PAT甲级1097详解附AC代码

2301_79601095的博客 1060

当NetApp 7-mode遇到单控制器故障:HA模式手动修复全记录

本文详细记录了NetApp 7-mode存储系统在单控制器故障时的应急修复过程,包括HA配置重建、磁盘初始化和业务恢复等关键步骤。通过实战案例解析如何解决`VIA Interconnect is down`等典型问题,为企业级存储系统的高可用保障提供实用指南。

yolo5detector的博客 247

「1097」Deduplication on a Linked List

Given a singly linked listLwith integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each valueK, only the first node of which the v...

weixin_52435933的博客 200

实战篇【2】-H3C防火墙开局基础配置

本篇文章为“H3C防火墙开局基础配置”,主要涵盖配置管理地址、聚合端口、安全区域、安全策略、静态路由、ACL,WEB和SSH远程管理、Console、SNMP、NTP时钟、日志主机等内容,对比交换机配置开局,增加两处配置,安全区域和安全策略。方便调试人员远程管理、调试。

weixin_47402139的博客 1万+

Valgrind 从入门到精通:内存调试和性能分析

Valgrind 提供了强大的 API,允许开发者编写自定义的检查工具。通过扩展 Valgrind,可以针对特定场景实现更精准的检测。

大模型大数据攻城狮的专栏 1218

PAT (Advanced Level) - 1097 Deduplication on a Linked List

链表

https://www.hyperplasma.top 378

农业无人机:无人机图像处理_(8).遥感图像处理与分析

遥感图像处理与分析在农业无人机技术中具有重要作用,通过图像预处理、特征提取、分类与分割、目标检测等技术,可以实现对农田的精细管理、作物监测、病虫害预测等应用。本节详细介绍了这些技术的基本概念、常用方法和具体实现,希望对您在农业无人机图像处理方面的学习和应用有所帮助。

zhubeibei168的博客 1336

1097 Deduplication on a Linked List (25 point(s))

求解 写了两种代码,不过第一种还是不知道错在哪,有知道的老铁麻烦告知一下,谢谢。 #include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;vector&gt; #include&lt;cmath&gt; using namespace std; const int MAXN = 1e6; const int MAXM =...

徐伯莱 307

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

1097 Deduplication on a Linked List (25point(s))

1097 Deduplication on a Linked List (25point(s)) Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or absolute

佳迪斯的博客 127

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

1097 Deduplication on a Linked List (25 point(s))

Given a singly linked listLwith integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each valueK, only the first node of which the value or a...

张蔡辉 188

1097 Deduplication on a Linked List (25 point(s)) PAT甲级

1097 Deduplication on a Linked List (25 point(s)) 链表 题目 Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or a

neko的博客 169

PAT----A1097 Deduplication on a Linked List (25point(s))

A1097 Deduplication on a Linked List (25point(s)) 题意 绝对值相同的节点另成一条链表 思路 按照题意写即可。 总结 简单链表操作题。 Sample Input: 00100 5 99999 -7 87654 23854 -15 00000 87654 15 -1 00000 -15 99999 00100 21 23854 Sample Outp...

qq_43578870的博客 163

PAT(甲级)1097 Deduplication on a Linked List (25point(s))

题目 题目链接 思路 为每一个节点赋一个 order 属性,未删去有效节点的 order 在 [0 ~ maxn) 内;删去的有效节点的 order 在 [maxn, 2 * maxn) 内;无效节点的 order 在[2 * maxn, 3 * maxn) 内;因为节点最多有maxn,顶多全部是有效的或全部是无效的; 遍历链表的时候判断每一个节点的绝对值是否出现过,没有出现过就让 valid 值加一,否则 invalid 值加一,valid 和 invalid 分别代表未删去的有效节点个数和已删去的有效节

hjyp的博客 127

1097 Deduplication on a Linked List (25point(s)) - C语言 PAT 甲级

* 第一遍遍历,利用 num[] 数组输出绝对值不重复的节点,并把输出的节点标记 * 第二遍遍历,输出未被标记的节点

有三只土豆 205

PAT_甲级_1097 Deduplication on a Linked List (25point(s)) (C++)【删除链表重复节点】

目录 1,题目描述 题目大意 2,思路 3,AC代码 4,解题过程 第一搏 第二搏 1,题目描述 Sample Input: 00100 5 99999 -7 87654 23854 -15 00000 87654 15 -1 00000 -15 99999 00100 21 23854 Sample Output: 00100 21 23854 2385...

&再见萤火虫&的博客 175

1097. Deduplication on a Linked List (25)[链表]

1. 原题:https://www.patest.cn/contests/pat-a-practise/1097 2.思路: 题意:链表题 给出一个静态链表信息,去掉所有数据值(绝对值)重复的结点。 最后输出挑选出的链表和废弃的被移除的结点组成的链表。 思路: 有多个方法,可以用数组。我这里用的stl里的map。 把读入的结点存入map中。 然后再从起点开始读,第一次出现的值的结点

坚不萌 383

PAT 1097 Deduplication on a Linked List(25分)

静态链表

cwtnice的博客 900

PAT 甲级 1097  Deduplication on a Linked List

1097 Deduplication on a Linked List (25 point(s)) Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each v...

漫浸天空的雨色的备忘录~ 705

list_1097 Deduplication on a Linked List (25 分)

1097 Deduplication on a Linked List (25 分) Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K,...

A_Bo的博客 432

1097 Deduplication on a Linked List

题目 题意:给定原链表,原链表只保留绝对值第一次出现的元素,其余重复元素放到移出链表内 tip:链表删除操作 #include<iostream> #include<set> #include<cmath> using namespace std; int main() { int s,n; cin>>s>>n; int ...

qq_1300258993的博客 393

1097 Deduplication on a Linked List (25 分)

1097Deduplication on a Linked List(25分) Given a singly linked listLwith integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each valueK,...

chen_zan_yu_的博客 131
上一篇: 1106 Lowest Price in Supply Chain (25 point(s))
下一篇: 1136 A Delayed Palindrome (20 point(s))
coderwait
博客等级 码龄9年 20粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值