#P1706. References

References

题目描述

电子杂志的编辑们以文本文件形式生成文档的草稿版本。然而,出版物需要满足特定要求,尤其是关于引用使用的规则。遗憾的是,许多草稿文章违反了这些规则。因此,开发一个计算机程序,将草稿版本转换为符合所有规则的出版物是非常必要的。

我们将“段落”定义为文章中连续排列的一组行,段落之间由至少一个空行(即仅包含空格的行)分隔。任何段落都可以包含任意数量的引用。引用是一个用方括号括起来的正整数(不超过999999),例如:[23][23]。方括号与数字之间没有空格,且方括号仅用于引用。

段落分为两种类型:“常规段落”和“引用描述段落”。引用描述段落与常规段落的区别在于,它以所描述的引用开头,例如: [23][23] 这是描述内容... 引用描述段落的首行以方括号开头(即前面没有空格),且段落内部不会包含其他引用。

每个引用对应唯一的描述,每个描述至少对应一个引用。

将草稿转换为出版物时,必须遵循以下规则: 1.1. 引用必须按照在常规段落中首次出现的顺序,依次重新编号为从11开始的连续整数。 2.2. 引用描述必须按编号顺序排列在文章末尾。 3.3. 常规段落的顺序必须保持不变。 4.4. 程序不得对段落进行其他修改。

输入

输入文件是一个需要处理的草稿文章文本文件。所有行不超过8080个字符。任何引用描述段落不超过33行。输入文件最多包含40,00040,000行。

输出

输出文件是处理后的结果。所有段落之间用一个“真”空行(即不包含任何字符的行)分隔。文章开头不能有空行。

输入示例1

[5] Brownell, D, "Dynamic Reverse Address Resolution Protocol
    (DRARP)", Work in Progress.

The Reverse Address Resolution Protocol (RARP) [10] (through the
extensions defined in the Dynamic RARP (DRARP) [5]) explicitly
addresses the problem of network address discovery, and includes an
automatic IP address assignment mechanism.

[10] Finlayson, R., Mann, T., Mogul, J., and M. Theimer, "A Reverse
        Address Resolution Protocol", RFC 903, Stanford, June 1984.

[16] Postel, J., "Internet Control Message Protocol", STD 5, RFC 792,
        USC/Information Sciences Institute, September 1981.


The Trivial File Transfer Protocol (TFTP) [20] provides for transport
of a boot image from a boot server.  The Internet Control Message
Protocol (ICMP) [16] provides for informing hosts of additional routers
via "ICMP redirect" messages.

[20] Sollins, K., "The TFTP Protocol (Revision 2)",  RFC 783, NIC,
     June 1981.

Works [10], [16] and [20] can be obtained via Internet.

输出示例1


The Reverse Address Resolution Protocol (RARP) [1] (through the
extensions defined in the Dynamic RARP (DRARP) [2]) explicitly
addresses the problem of network address discovery, and includes an
automatic IP address assignment mechanism.

The Trivial File Transfer Protocol (TFTP) [3] provides for transport
of a boot image from a boot server.  The Internet Control Message
Protocol (ICMP) [4] provides for informing hosts of additional routers
via "ICMP redirect" messages.

Works [1], [4] and [3] can be obtained via Internet.

[1] Finlayson, R., Mann, T., Mogul, J., and M. Theimer, "A Reverse
        Address Resolution Protocol", RFC 903, Stanford, June 1984.

[2] Brownell, D, "Dynamic Reverse Address Resolution Protocol
    (DRARP)", Work in Progress.

[3] Sollins, K., "The TFTP Protocol (Revision 2)",  RFC 783, NIC,
     June 1981.

[4] Postel, J., "Internet Control Message Protocol", STD 5, RFC 792,
        USC/Information Sciences Institute, September 1981.

来源

Northeastern Europe 1997