#P6565. [NOI Online #3 入门组] 最急救助

[NOI Online #3 入门组] 最急救助

Problem Description

The rescue center receives many distress signals every day. After receiving a distress signal, the rescue center will analyze it and find the most urgent person to rescue.

A distress signal is a string consisting of lowercase English letters. The more times three consecutive characters in the string form sos in order (that is, the more substrings sos it contains), the more urgent the situation is.

Now please help the rescue center find the most urgent person. Note that the sos substrings in the string can overlap. For example, sosos is considered to contain 22 occurrences of sos.

Input Format

Read input from standard input.

The first line contains an integer nn, indicating the number of people asking for help.

The next 2×n2 \times n lines each contain a string of lowercase English letters. Among these 2×n2 \times n lines, the string on line 2×i12 \times i - 1 (1in1 \le i \le n) is the name of the ii-th person, and the string on line 2×i2 \times i is the distress signal of the ii-th person.

Output Format

Write output to standard output.

There are two lines in total. The first line contains the name(s) of the most urgent person(s). If there are multiple most urgent people, output their names in the input order, separated by a space.

The second line contains an integer, indicating how many sos substrings are contained in the distress signal of the most urgent person.

2
adam
ineedhelpsosineedhelpsos
mark
ineedmorehelpsoshelpmesossoshelpme
mark
3
3
susan
sosososososos
jack
sossossossos
allen
soshelpsossossossossos
susan allen
6

Hint

Constraints

  • For 10%10\% of the testdata, n=1n = 1.
  • For all testdata, 1n1001 \leq n \le 100, the length of each name is at most 2020, and the length of each distress signal is at most 200200.

Translated by ChatGPT 5