编程介的小学生 2017-09-23 14:08 采纳率: 20.5%
浏览 884
已采纳

Data, Data, Everywhere

You've been asked to make a simple text-based database that can store any number of fields associated with records. IDs can contain letters, numbers, dashes (-), and slashes (/), and are case-sensitive. The standard data format for input and output is:
record-id
field-id
some data here
terminated with
a single period
.

There are NO blank lines between entries.

Some commands have lists of record IDs or field IDs. These are comma-separated lists of IDs (no spaces) that specify the order of the output. * can be specified instead of a list of IDs. If * is specified for the record IDs, treat it as a comma-separated lexicographically sorted list of all the record IDs with at least one field in the database. If * is specified for the field IDs, treat it as a comma-separated lexicographically sorted list of all the field IDs defined by at least one record in the database.

The list of commands and their parameters follows:

Command Description
show For the specified records, display the values of the specified fields. This command takes two parameters, a list of record IDs and a list of field names. Both are comma-separated lists (no spaces) which specify which entries to display and in what order to display them. Output should follow the standard entry format and should be terminated by a line containing a single asterisk.
If a record does not have data for a field, then display the following entry for that record:

record-id
field-name
NO DATA
.

rem The program should ignore the text.
append Read in text and add it to the end of the specified entry, creating the entry if necessary. Input is terminated with a single period.
delete For the specified records, delete the values of the specified fields. This command takes two parameters, a list of record IDs and a list of field names.
done Stop processing this list of commands.

Input

Read commands from the input, one command per line. There will be at most 50,000 lines in the input (including any read files), a mix of commands and data. IDs will be at most 64 characters long. There will be at most 10,000 field IDs and 10,000 record IDs defined at any given time, although more may be defined after the old IDs have been deleted. Each line will be at most 255 characters long. Record field data will be at most 2,000 lines long.

Output

Only the show command produces output. Print the output in the standard data format to the standard output stream.

The program should finish the given input within 60 seconds.

Sample Input

append team-bar prob-b
1400 Accepted.
.
append team-foo prob-a
1305 Wrong answer.
.
show team-foo,team-bar *
append team-foo prob-a
1402 Accepted.
.
rem Hmm...
delete team-bar *
.
show * *
done

Sample Output

team-foo
prob-a
1305 Wrong answer.
.
team-foo
prob-b
NO DATA
.
team-bar
prob-a
NO DATA
.
team-bar
prob-b
1400 Accepted.
.
*
team-foo
prob-a
1305 Wrong answer.
1402 Accepted.
.
*

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-10-11 10:38
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置