pat a1032 Sharing ------共有后缀

基于JavaFX的Http Server模拟器 源码地址 GitHub - DayRain/http-server-simulator: http server 模拟器 功能描述 HttpServer模拟器,通过简单的配置即可模拟第三方服务端,用于接收和响应HTTP请求。 支持同时模拟多个服务、动态添加接口、动态配置返回值。 使用说明 运行 exe运行 编译代码后,点击exe直接运行 代码运行 下载好代码后,运行主类ApplicationStarter即可 新建服务 主界面如下 点击 文件-新建 创建新的服务 ... 阅读详情

To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example, loading and being are stored as showed in Figure 1.

fig.jpg

Figure 1

You are supposed to find the starting position of the common suffix (e.g. the position of i in Figure 1).

Input Specification:

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

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

Address Data Next

whereAddress is the position of the node, Data is the letter contained by this node which is an English letter chosen from { a-z, A-Z }, and Next is the position of the next node.

Output Specification:

For each case, simply output the 5-digit starting position of the common suffix. If the two words have no common suffix, output -1 instead.

Sample Input 1:

11111 22222 9
67890 i 00002
00010 a 12345
00003 g -1
12345 D 67890
00002 n 00003
22222 B 23456
11111 L 00001
23456 e 67890
00001 o 00010

Sample Output 1:

67890

Sample Input 2:

00001 00002 4
00001 a 10001
10001 s -1
00002 a 10002
10002 t -1

Sample Output 2:

-1

 

#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;

const int maxn=100010;

struct Node
{
	char data; 
	int next;
	bool flag;
}node[maxn];

int main()
{
	//存储空间的所有节点flag位置为false 
	for(int i=0;i<maxn;i++)
	{
		node[i].flag=false;				
	}
	int s1,s2,n;
	scanf("%d%d%d",&s1,&s2,&n);
	
	int address,next;
	char data;
	
	//n个节点信息的输入 
	for(int i=0;i<n;i++)
	{
		scanf("%d %c %d",&address,&data,&next);
		node[address].data=data;
		node[address].next=next;
	}
	
	int p;
	//第一条链表的所有节点的flag位置为true 
	for(p=s1;p!=-1;p=node[p].next)
	{
		node[p].flag=true;		
	}
	
	//遍历第二条链表的全部节点,看其中是否有标志位为true的节点 
	for(p=s2;p!=-1;p=node[p].next)
	{
		if(node[p].flag==true) break;		
	}
	
	if(p!=-1)
	{
		printf("%05d\n",p);
	}
	else
	{
		printf("-1\n",p);
	}
	return 0;
}

 

PMO与供应链管理的整合:端到端项目交付的优化策略 在当今全球化和市场竞争日益激烈的环境中,组织面临着前所未有的项目复杂性和交付压力。传统上相互独立的项目管理办公室(PMO)与供应链管理(SCM)正逐渐意识到:只有通过无缝整合,才能实现真正高效的端到端项目交付。本文深入探讨了PMO与供应链管理整合的战略价值、核心框架和实施路径,通过生动的比喻、实际案例和实用工具,展示了如何打破部门壁垒,构建协同高效的项目生态系统。无论您是PMO负责人、供应链专业人士还是高级管理层,都将从本文获得重塑项目交付模式、优化资源利用、降低风险并提升组织竞争力的宝贵见解和行动指南。 阅读详情

相关推荐

MaxKey+JeecgBoot单点登录实战:手把手教你从零配置到账户同步

本文提供MaxKey与JeecgBoot单点登录(SSO)的实战整合指南。详细讲解从MaxKey应用注册、JeecgBoot前后端改造,到最终实现账户同步的完整步骤,重点解决Shiro配置、令牌交换等关键问题,帮助企业构建统一、可扩展的身份管理体系。

weixin_29258297的博客 542

pat甲级1032 Sharing

To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example, and are stored as showed in Figure 1.Figure 1You are

2303_76815666的博客 840

深入剖析STM32F103 I2C总线死锁问题及高效应对策略

本文深入剖析了STM32F103硬件I2C总线在轮询模式下发生死锁的根本原因,即硬件状态机的预取机制与软件响应速度不匹配。文章提供了高效的解决方案,包括在轮询模式下提前发送NACK/STOP信号、降低总线速度,以及治本的中断与DMA应用策略,帮助开发者根据项目需求选择最合适的方案,彻底解决这一经典硬件缺陷问题。

weixin_29184371的博客 206

(PAT甲级) 1032 Sharing (静态链表)

地址范围很小,可用静态链表。

zeng_han_cheng的博客 437

cartographer错误终结者 ordered_multi_queue.cc:155 Queue waiting for data

错误描述 错误提示的感应器数据可能是: Queue waiting for data:(0, points2) Queue waiting for data:(0, odom) 说明在提供给cartographter的传感器数据出现了问题,没有被成功解析。 原因分析 小编是使用自己编写的odom话题发布时,cartographer爆出了该错误。 于是设想传感器数据相关的tf或lua配置或数据本身存在错误。 于是逐个排查,最终发现了错误原因。 排查可能原因:tf错误 小编之前已处理过tf与lua配置的问题 参

人工智能机器人 4157

从萤石云到GB28181:海康4G摄像机接入第三方平台的曲折之路

本文深入探讨了海康4G摄像机接入第三方平台时遇到的协议冲突问题,特别是GB28181与萤石云服务的互斥性。通过技术分析揭示了4G模块的定向流量限制和协议栈资源竞争等核心问题,并提供了有线接入测试和萤石云API二次开发等解决方案。最后总结了设备选型的关键参数和协议兼容性检查清单,为安防监控系统集成提供实用指导。

mango的博客 997

PAT 甲级 1032 Sharing

To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example, and are stored as showed in Figure 1.Figure 1You are

m0_51711089的博客 215

图解基站机房:AAU、RRU与BBU之间的线缆连接与规格选择

本文以图解方式详解了5G基站机房中AAU、RRU与BBU三大核心设备之间的线缆连接方案与规格选择。重点阐述了电力线(如2×10 mm²直流电缆)、数据光缆(如野战光缆与波分复用)及射频馈线的功能、选型标准与实战布线法则,为通信工程部署与维护提供清晰指导。

weixin_29306011的博客 503

PAT 1032 Sharing

1032 SharingTo store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example, and are stored as showed in Figure 1.Figu

weixin_50679551的博客 265

PyTorch实战:用FGSM攻击MNIST分类器(附可视化对比)

本文通过PyTorch实战演示了如何使用FGSM对抗攻击方法攻击MNIST手写数字分类器。文章详细解析了FGSM攻击原理,提供了从环境搭建、模型准备到攻击实施、可视化对比的完整代码实战流程,并探讨了对抗样本的生成与模型鲁棒性评估。

3a9bq4r8t2y的博客 216

可食用野生植物检测实战:基于YOLOv11的智能识别系统全流程指南

本文介绍了一种基于YOLOv11的可食用野生植物智能识别系统。该系统通过深度学习技术,能在0.2秒内精准识别植物是否可食用,准确率高达92%。文章详细阐述了从数据采集、标注到模型训练、验证的全流程,并开发了用户友好的Tkinter交互界面。该系统解决了户外探险和植物研究中植物识别的痛点,具有高精度、实时性和强泛化能力的特点,为户外安全提供了智能化解决方案。

FJN110的博客 164

1032 Sharing (25)

To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example,...

ysq96的博客 397

Python蓝色跳动的爱心(完整代码)

Python语言实现蓝色跳动的爱心的完整代码。 代码分析 这段代码使用了 库来创建一个动态的爱心图案,并在屏幕上显示带有动态效果的“我爱你”字样。以下是对这段代码的详细分析: 用于创建图形用户界面(GUI)。 用于生成随机数,主要用于控制爱心图案的扩散效果。 中的 , , , 用于数学计算,生成爱心形状和扩散效果。 包含了 等常量,用于控制控件的对齐方式。 2. 全局变量定义 , : 定义画布的大小。 , : 爱心的中心坐标。 : 用于定义爱心形状的缩放

AIGC 1921

PAT甲级 1032 Sharing

PAT甲级 1032 Sharing 题目链接 To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example, loading and being are stored as

旺崽的博客 2539

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

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

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

PAT 1032. Sharing

题目:http://pat.zju.edu.cn/contests/pat-a-practise/1032 题解: 给两个字符串的链表存储,如果两个字符有相同的后缀,其后缀会存放在相同内存块,问这两个字符串是否有相同的后缀,如果有相同的后缀求出最开始相同的字母的内存地址。 先遍历一个字符串,标记出现过哪些地址,再遍历另一个字符串,出现相同地址的即所求解。 注:竟然卡STL C中格式字符串

Ted's 游乐园 1926

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

PAT A1032 Sharing

PAT A1032 Sharing Sample Input 1: 11111 22222 9 67890 i 00002 00010 a 12345 00003 g -1 12345 D 67890 00002 n 00003 22222 B 23456 11111 L 00001 23456 e 67890 00001 o 00010 Sample Output 1: 67890 Sam...

qq_42347617的博客 230

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

PAT甲级:1032 Sharing

文章目录1032 Sharing (25 分)Input Specification:Output Specification:Sample Input 1:Sample Output 1:Sample Input 2:Sample Output 2:实现思路:第一次代码 1032 Sharing (25 分) To store English words, one method is to us...

wvdon 401

PAT A1032. Sharing (25)

原文链接: PAT A1032. Sharing (25) ...

阿豪 146

1032 Sharing——PAT甲级(测试点4分析)

To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example, and are stored as showed in Figure 1.Figure 1You are

flyidj的博客 1946

【PAT甲级 - C++题解】1032 Sharing

📣专栏定位:为想考甲级PAT的小伙伴整理常考算法题解,祝大家都能取得满分!

Newin2020的博客 807

PAT甲级 A1032

PAT甲级 A1032 题目详情 1032 Sharing (25分) To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example, loading and being a

weixin_44065549的博客 265

PAT A 1032(甲级)

1032 Sharing(25 分) 作者: CHEN, Yue 单位: 浙江大学 时间限制: 200 ms 内存限制: 64 MB 代码长度限制: 16 KB To store English words, one method is to use linked lists and store a word letter by letter. To save some space, ...

CrazyOnes的博客 1053

[PAT A1032]Sharing

[PAT A1032]Sharing 题目描述 To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the...

欢迎来到我的编程小屋 655

1032 Sharing (25 分)

1032 Sharing (25 分) To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same ...

92377 707

【PAT】A1032 Sharing【链表】

To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example,...

elegant coder 850

PAT-A1032 Sharing【链表】

To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example,loadingandbeingare stored as showed in Figure 1. ...

gdc6916的博客 3万+
上一篇: 单链表的基本操作
下一篇: pat a1052 Linked List Sorting ------ 静态链表排序
Estrellas_
博客等级 码龄9年 273粉丝 233原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值