#include<stdio.h>
#include<algorithm>
using namespace std;
#define MAX_N 100005
//const int MAX_N=100005
struct Node{
int next;
int data;
int address;
bool flag;
}node[MAX_N];
int n,head;
bool cmp(struct Node a,struct Node b){
if(a.flag!=b.flag) return a.flag>b.flag;
else return a.data<b.data;
//if(a.data!=b.data) return a.data<b.data;
//不处理相等的情况会出现段错误
}
int main(){
int address;
scanf("%d%d",&n,&head);
for(int i=0;i<n;i++){
scanf("%d",&address);
scanf("%d%d",&node[address].data,&node[address].next);
node[address].address=address;
}
int count=0;
for(int p=head;p!=-1;p=node[p].next){
node[p].flag=true;
count++;
}
if(count==0)
printf("0 -1");
else{
sort(node,node+MAX_N,cmp);
printf("%d %05d\n",count,node[0].address);
for(int i=0;i<count;i++){
if(i!=count-1)
printf("%05d %d %05d\n",node[i].address,node[i].data,node[i+1].address);
else
printf("%05d %d -1\n",node[i].address,node[i].data);
}
}
}
相关推荐
基于PINN的一个简单的求解偏微分方程实例
本人是做化工模拟的一名学生,最近在学习PINN(Physics-Informed Neural Networks,物理信息神经网络)对管道动力学进行建模研究,PINN由于其对机理与数据的良好兼顾性非常热门,本文是作者对PINN入门研究过程的一个练手小题目,main code也是作者代码是基于pytorch2.6.0写的,发上来供各位参考,欢迎研究管道动力学和PINN的小伙伴一起讨论~
1052 Linked List Sorting (25)(25 分)
A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the next structure. Now give...
跨域问题 - 其他 method 都没有跨域问题,只有delete有跨域的问题
跨域的配置等一切正常,GETPOSTPUTOPTIONS都可以正常访问, 唯独有一个DELETE有跨域的问题, 经过排查发现这个DELETE请求有body, 经过一系列排查, 发现头部有一个不太正常的值是为了避免浏览器的影响, 直接在 postman 中新建一个请求, 竟然也有跨域的问题, 后来把的值改成了请求就可以正常调用了.
pat1052Linked List Sorting (25)
题意分析: (1)给出内存中链表的节点,节点定义为:address value nextaddress并且给出链表的起始地址,按照原来的格式输出这个链表经过按照value排序后的链表,即:链表节点的个数 起始地址以及每个链表的节点 (2)因为涉及到链表节点的排序,先将链表的定义包装成结构体,然后按照value值进行排序,因为排序后address域没有发生变化,而nextAddress域变成了排
单片机通信总述——理论部分(CAN、串口、SPI、I2C等)
并行通信:传输原理:数据各个位同时传输;优点:速度快; 缺点:占用引脚资源多。是指使用 8、16、32 及 64 根或更多的数据线(有多少信号为就需要多少信号位)进行传输的通讯方式,可以同一时刻传输多个数据位的数据。串行通信: 传输原理:数据按位顺序传输;优点:占用引脚资源少; 缺点:速度相对较慢。是指设备之间通过一根数据信号线,地线以及控制信号线,按数据位形式一位一位地传输数据的通讯方式,同一时刻只能传输一位(bit)数据。 单工: 数据传输只支持数据在一个方向上传输。信息只能单方向传输的工作方式,一
张量分解浅谈(四 Tucker 分解)
学完了SVD算法之后,我们继续回到张量几大分解的学习上来,本期学习的主要内容是张量的 Tucker 分解 以及 前面的CP分解还留下一点没有说完,正好一并补齐!后面的公式我将采用颜色标记,红色代表必须掌握,蓝色尽量掌握! 在这之前先附一张图,包含了各种运算符号的名称含义,大部分是前面说过或者使用过的: Tensor decomposition一 . Tucker 分解公式介绍和原理二 . 张量的 n-Rank 一 . Tucker 分解公式介绍和原理 我们先来看一张被使用过很多次的Trucker 分解图
PAT甲级 1052 Linked List Sorting (25分)
1052 Linked List Sorting (25分) 题目链接:PAT A 1052 题目大意:这道题要求对给定的每个链表组成结构(即节点)按照key值从小到大排序,输出排序后链表的节点个数,头结点,以及链表中的每个结构。 思路分析:PAT里的链表题地址基本都是由五六位的数字构成,非常清晰直观,因此我们可以使用静态链表来解决。所谓静态链表,就是结构体里的next变量不再是指针类型,而是整...
[代码开源]基于DistFlow的IEEE33和IEEE69节点最优潮流模型(OPF)实现与性能分析
本文详细介绍了基于DistFlow的IEEE33和IEEE69节点最优潮流模型(OPF)的实现与性能分析。通过代码开源,展示了如何从零搭建电力系统优化模型,解决配电网中的发电成本最小化问题。文章涵盖数据准备、模型实现细节、性能优化建议及常见问题解答,为电力系统研究者提供实用参考。
1052 Linked List Sorting (25 分)-PAT甲级
A linked list consists of a series of structures, which are not necessarily adjacent in memory(在内存中相邻). We assume that each structure contains an integerkeyand aNextpointer to the next structure. Now given a linked list, you are supposed to sort the st...
YOLO26全网首发:CVPR2026 FAA| 解决YOLO Neck跨尺度方向冲突--- FAAFusion频域对齐融合模块 | 暴力涨点篇
本文改进:FAAFusion引入YOLO neck ,代替nn.Upsample和Concat
【异常】Milvus 向量数据库字段缺失错误分析与解决 MilvusVectorStoreServiceV2 - Failed to insert batch [0-1]: The field:
本文分析了Milvus向量数据库插入操作中出现的字段缺失错误。错误显示age_mode字段未提供,导致批量插入失败。根本原因是Milvus Schema要求所有定义字段必须存在,但代码中对部分字段采用条件添加方式。解决方案是将条件添加改为始终添加,为可能为null的字段提供空字符串默认值。文章总结了Schema约束、防御性编程等经验,并建议通过Schema变更检查、单元测试覆盖和数据校验层等预防措施避免类似问题。该问题影响product、mac、source等多个字段,修改后确保了数据插入的可靠性。
PAT甲级 1052 Linked List Sorting (25 分)
\quad一开始我以为这就是个简单的排序题,不需要简历链表,只需要用结构体存储下信息排序输出即可。后来才发现题目中给出的节点可能并不能建立一个链表,有些接点是孤立点,甚至没有一个合法的接点。因此只能建立链表,并通过题目给出的头结点地址遍历整个链表找出合法的接点,并统计合法链表的个数,然后再排序输出,程序如下: #include <bits/stdc++.h> using namespa...
核心组件大换血:Backbone与Neck魔改篇:YOLO26魔改Neck:引入BiFPN(双向特征金字塔),多尺度融合能力飙升
本文深入解析了YOLO26目标检测模型中Neck部分的优化策略,重点探讨了BiFPN(双向特征金字塔网络)的原理与实现。文章首先指出YOLO26原生FPN+PAN结构在多尺度特征融合上的局限性,特别是在小目标检测和边缘部署场景中的性能瓶颈。随后系统梳理了Neck网络的演进历程,从FPN、PANet到BiFPN和ASFF,详细对比了各架构的特点。核心部分展示了如何将BiFPN引入YOLO26,包括可学习权重融合、双向跨尺度连接等关键技术实现,并提供了PyTorch代码示例。本文为需要提升小目标检测性能或优化边
PAT A 甲级 1052 Linked List Sorting (25分)
1052 Linked List Sorting (25分) 吐槽 我最怕的就是用时极限的题目。不仅难想,而且凡改必大改,极度耗时。 思路 本题的主干部分非常简单,就是个排序。重点是超时问题以及大量没有明说的测点问题。 先说明测点问题,因为超时问题中有一部分是测点导致的。 首先,仅从题目来看,input中的“next”似乎是没用的——反正后面也要按key重新排序。然而实际上,这是有用的——有些数据...
华为的C语言编程规范.pdf
华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。
VC中sqlite的使用
在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示
【PAT甲级】1052 Linked List Sorting (25 分)
题意: 输入一个正整数N(<=100000),和一个链表的头结点地址。接着输入N行,每行包括一个结点的地址,结点存放的值(-1e5~1e5),指向下一个结点的地址。地址由五位包含前导零的正整数组成。以头结点地址开始的这条链表以值排序后得到的链表的长度和头结点,接着以升序按行输出每个结点的地址和值以及指向下一个结点的地址。 trick: 题干说的postive N可是数据点4出...
假人有限元模型
假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用
1052. Linked List Sorting (25)-PAT甲级真题
1052. Linked List Sorting (25) A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next poi
efm32 入门.pdf
本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。
PAT甲级1052:Linked List Sorting (25)
题目 A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the next structure. Now given a linked list, you are supposed to sort the structu
PAT甲级-1052 Linked List Sorting (25分)
点击链接PAT甲级-AC全解汇总 题目: A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the nex...
【PAT甲级】1052 Linked List Sorting (25分)
解题过程的小记录,如有错误欢迎指出。 难度:一星(在做完1012后弄懂排序规则后此题并不难) 小导航~题目分析注意点我的解题过程思路bug代码dalao的代码借鉴点 题目分析 注意点 我的解题过程 思路 bug 代码 dalao的代码 全部代码因版权原因不放出来,大家可以自行去柳神博客购买或者参考晴神的上机笔记~ 借鉴点 ...
PAT(甲级)1052 Linked List Sorting (25 分)
A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the next structure. Now give...
PAT甲级1052 Linked List Sorting (25 分)
1052Linked List Sorting(25分) A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integerkeyand aNextpointe...
PAT 甲级A1052 Linked List Sorting (25 分)
题目: 1052 Linked List Sorting (25 分) A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next ...
PAT 甲级 1052 Linked List Sorting (25分)
题目 1052 Linked List Sorting (25分) A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the next structure. Now given a linked list, you a
PAT甲级A1052 Linked List Sorting (25 分)
A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Next pointer to the next structure. Now give...
PAT 甲级 1052 Linked List Sorting (25 分)
A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integerkeyand aNextpointer to the next structure. Now give...
1740



被折叠的 条评论
为什么被折叠?



