#LX0025. [ICPC2024 Xi'an I] Rubbish Sorting
[ICPC2024 Xi'an I] Rubbish Sorting
中文翻译:
有次信息,每次信息是以下两种:
(1)给你一个小写字母串,并告诉你他是哪一类垃圾。
(2)给你一个小写字母串,问他跟哪一类垃圾最接近,如果有多解,输出编号最小的那一个。
小写字母串长度不超过,接近的定义是:有多少个位置,满足。
题目描述
Bob has many pieces of rubbish. One day, he wants to sort them.
For every piece of rubbish, its type is expressed as a positive integer.
He has operations. For each operation, it is one of the following two operations.
1 s x
He tells you that the piece of rubbish named has a type of .2 s
He wants to ask you the type of rubbish .
But his memories are not always accurate.
For each operation , may not have appeared in the previous operation s.
We define the similarity of two strings and as .
Here all the strings' indexes start at .
For a string , its type is the type of string which has the maximum similarity to among all the strings that have appeared in the previous operations s. Note that if there are multiple strings that all have the maximum similarity to , the type of is the minimum type of these strings' type.
Now, he wants you to solve this problem.
输入格式
The first line contains an integer , which is the number of operations.
Next lines contain operations, one per line. They correspond to the description given in the statement.
It is guaranteed that for every operation there is at least one operation before it.
But some pieces of rubbish will have more than one type, you can consider it as the minimum type you have read.
The rubbish's names only consist of lowercase Latin letters.
输出格式
For every operation , you should print an integer in a single line that is the rubbish 's type.
4
1 aaa 1
2 aa
1 ab 2
2 bb
1
2
相关
在以下作业中: