1097. Deduplication on a Linked List (25)

单片机毕业设计-基于STM32单片机的智能镜系统-仿真设计 可通过MQ-2监测当前烟雾浓度可通过温湿度传感器监测当前温湿度可通过光照强度传感器监测光照强度可通过蜂鸣器进行烟雾报警可通过语音识别模块进行反馈播报状态可通过按键设置阈值三个继电器控制灯、加湿、风扇标签:STM32单片机、OLED112864、DHT11、BH1750、继电器、SU-03T、MQ-2、蜂鸣器题目扩展:智能家居安防、智能大棚控制系统、智能环境检测系统项目编号:ZL-32-240604-FZ。 阅读详情

1097. Deduplication on a Linked List (25)

时间限制
300 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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 (<= 105) 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 104, 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

注意如果全部都是不相同的情况

code:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <cmath>
using namespace std;
struct node{
    int ad;
    int v;
    int Next;
}L[100010],ans[100010],rmove[100010];
int main(){
    int onset;
    int n;
    int vis[100010];
    memset(vis,0,sizeof(vis));
    scanf("%d%d",&onset,&n);
    for(int i = 0; i < n; i++){
        int ad,v,Next;
        scanf("%d%d%d",&ad,&v,&Next);
        L[ad].ad = ad;
        L[ad].v = v;
        L[ad].Next = Next;
    }
    int x = onset;
    int cnt1 = 0,cnt2 = 0;
    while(x != -1){
        int ab = abs(L[x].v);
        if(!vis[ab]){
            vis[ab] = 1;
            ans[cnt1++] = L[x];
        }
        else{
            rmove[cnt2++] = L[x];
        }
        x = L[x].Next;
    }
    int i;
    for(i = 0; i < cnt1-1; i++){
        printf("%05d %d %05d\n",ans[i].ad,ans[i].v,ans[i+1].ad);
    }
    printf("%05d %d -1\n",ans[i].ad,ans[i].v);
    if(cnt2){//如果需要去掉的有才输出
        for(i = 0; i < cnt2-1; i++){
            printf("%05d %d %05d\n",rmove[i].ad,rmove[i].v,rmove[i+1].ad);
        }
        printf("%05d %d -1",rmove[i].ad,rmove[i].v);
    }
    return 0;
}


uniapp - 热更新提示:WGT安装包中manifest.json文件不存在 | unexpected EOF!报错详细解决,完美搞定WGT安装包中WWW目录下manifest.json不存在问题 uniapp,安卓android,苹果ios,热更新,热更新code:-1202报错,,WGT热更新报错,uniapp热更新wgt出现报错manifest.json文件不存,uniapp安卓苹果软件热更新时出现错误unexpected EOF!如何解决,怎么解决热更新wgt报错,app新版本下载安装报错WGT安装包中manifest.json文件不存在,WGT安装包中WWW目录下manifest.json不存在,uniapp热更新报错安装失败[-1201]:WGT/WGTU文件格式错误,uniapp-wgt 阅读详情

相关推荐

Dzzoffice结合OnlyOffice 报错排查流程总结

首先访问 OnlyOffice 首页,如下图:出现上图仍旧不能说明你的 OnlyOffice 服务已经成功安装,我们需要启动 OnlyOffice 服务测试用例来检测,可以看到上图出现了两条命令,第一条命令是用来启动测试用例服务的,我们只需要在后台执行该命令即可,Windows环境是以管理员身份运行Windows PowerShell输入即可运行了。

小胡的博客 4595

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

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

坚不萌 383

差分音频转单端音频单电源方案

其中,芯片设计中的轨到轨输出(Rail-to-Rail Output) 是指通过特定的电路设计,使芯片(如运算放大器、驱动电路等)的输出电压能够达到或接近电源电压的上下极限(即“电源轨”),从而最大化信号的动态范围。最终,Vout=R2/R1*(Vin2−Vin1),即输出电压为输入电压差(Vin2−Vin1)乘以电阻比R2/R1。2、电阻:R1、R2、R3、R4是电路中的电阻,其中R1 = R3,R2 = R4。因R1=R3,R2=R4,且Vn=Vp,设R1=R3=R,R2=R4=kR。

电子绿洲的博客 4955

1097 Deduplication on a Linked List (25分)

1 题目 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...

韩江雪de 小屋 646

Vivado ILA抓不到低频信号?试试Capture Control模式,保姆级配置教程(附PWM调试实例)

本文详细解析了Vivado ILA的Capture Control模式在低频信号捕获中的应用,特别针对PWM调试等场景提供保姆级配置教程。通过条件采样和时间拉伸技术,有效解决传统ILA采样在低频信号调试中的存储深度不足、关键信号丢失等问题,并附赠呼吸灯PWM的完整调试实例,帮助FPGA开发者提升调试效率。

weixin_42549451的博客 348

PRD撰写效率翻倍秘籍:我是如何用大模型+飞书文档搭建自动化工作流的

本文分享了如何利用大模型与飞书文档构建自动化工作流,以大幅提升PRD撰写效率。通过结构化需求输入、设计模块化提示词模板,并借助自动化脚本桥接数据与文档,产品经理可将繁琐的文档撰写工作自动化,从而将精力聚焦于产品战略与用户洞察。

weixin_28520495的博客 404

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

PAT甲级1097详解附AC代码

2301_79601095的博客 1057

【论文阅读1】机理引导的残差学习用于电池全生命周期状态监测 | Nature Communications

本文提出了一种机理引导的残差学习框架,用于提升电池全生命周期内荷电状态(SOC)和健康状态(SOH)的监测精度。该方法融合等效电路模型的先验知识与机器学习,设计了修正模型和补偿模型两种通用框架。实验验证表明,该方法在三种不同类型电池数据集上均表现出色,SOC和SOH估计误差较传统方法降低50%以上,且在未见工况下仍保持良好外推能力。模型具有强鲁棒性,在减少训练数据量和降低采样频率时性能稳定,并兼具物理可解释性。该框架无需离线测试和运行中校准,为电池安全监测提供了有效解决方案。

qq_21843433的博客 613

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,...

qq_41700374的博客 237

机器人常用坐标系详解:原理、获取方法及实战实例

本文系统阐述了机器人四大核心坐标系(世界、基、工具、工件)的原理与标定方法。世界坐标系提供全局参考基准,基坐标系绑定机器人本体,工具坐标系定义末端执行器位置,工件坐标系则锁定作业对象位置。通过齐次变换矩阵实现各坐标系间的关联转换。重点介绍了三类标定技术:手动设定法(世界坐标系)、三点/六点法(工具TCP标定)和视觉识别法(工件标定),并以工业机械臂上下料为例演示了完整应用流程。随着技术发展,自动化标定、动态坐标系等新趋势将进一步提升机器人作业精度与效率。

start_up_go的博客 512

西门子SMART PLC增量式PID(完整梯形图FC)

西门子PLC自带的PID指令是基于位置型的PID,位置型PID的算法公式和详细介绍,大家可以参看《PID专栏》的其它文章,这里不再赘述。本篇博文直接给出代码部分的讲解,不设计太多公式和理论的推导。限于本人能力,文中难免出现错误和不足之处,诚恳欢迎大家的批评和指正。同时感谢大家的订阅和关注。SMART200 PLC系统自带的PID指令解析,可以参看下面这篇文章:SMART PLC PID算法基本解析(附公式)_RXXW_Dor的博客-优快云博客_plc的pid算法在态运行中,控制器调节输出值,使偏差 (e

RXXW_Dor的博客 8146

【1097】Deduplication on a Linked List (25 分)

#include<iostream> #include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #include<algorithm> #include<map> #include<vector> #inclu...

发现问题,并解决问题,批判性思维 604

Python 爬虫教程:美食网站 + 社交平台餐馆评论抓取(评分提取 + 情感分析)

在当今数字化时代,数据无处不在,而爬虫技术则是获取数据的强大工具之一。无论是市场调研、学术研究还是个人兴趣探索,爬虫都能帮助我们从海量的网络信息中提取有价值的数据。本文将通过一个实战案例,带领大家学习如何使用 Python 爬虫技术抓取美食网站和社交平台上的餐馆评论,并进行评分提取与情感分析。通过这个项目,你将掌握爬虫的基本原理、数据解析、以及如何结合情感分析技术来挖掘数据背后的洞察。

u014481728的博客 310

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

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

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_的博客 130

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

PAT 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, ...

peanWang的博客 258

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

【PAT】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, only the first node of which the value or a

此去经年 795

PAT 1097 Deduplication on a Linked List(25分)

静态链表

cwtnice的博客 900
上一篇: 1094. The Largest Generation (25)(bfs)
下一篇: L2-021. 点赞狂魔
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值