PAT A 1032(甲级)

这篇博客介绍了PAT(A组)第1032题"Sharing",涉及如何使用链表存储英文单词并节省空间。文章讨论了如何找到共享后缀的起始位置,并提供了两种解决方法:一种是通过排序和搜索链表节点,另一种是利用节点标记已访问状态。博主分享了两种方法的AC代码,并邀请读者指正错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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, we may let the words share the same sublist if they share the same suffix. For example, loading and beingare 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 node

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值