P26449 [AtCoder] Atcoder Handles
普及
题目描述

Problem Description

Score: $ 250 $ points
Person X saw a list with $ N $ handles $ S_1, S_2, ..., S_N $.
However, some parts of the list are not visible. The invisible parts are represented by ?.
If Person X's handle $ T $ were included in the list, find all possible positions when $ N+1 $ people including Person X are sorted lexicographically.
Note that if there are people with the same name, either could come first.
Since there are no invisible parts, the lexicographical order of three handles would be e, petr, tourist.
Therefore, e is in the 1st position.


4
e
e
e
e
e

```

5
??
??
d?
?e
?f
zzz


 ```

7
atcoder
topcoder
codeforces
hackerrank
csacademy
codechef
atcoder
square

```

7
??i?
?o???g????
??m??x?
?h?????i
s????
?og????
u??
square


## Input Format

The input is given from the standard input in the following format:

> $ N $ $ S_1 $ $ S_2 $ : $ S_N $ $ T $

## Output Format

- Find all possible positions and output them in ascending order separated by spaces. (Do not add a space after the last number)
- Also, add a newline at the end.

## Sample Input and Output

### Sample Input #1

2
tourist
petr
e


### Sample Output #1

1
```### Sample Input #2

None

Sample Output #2

1 2 3
```### Sample Input #3

None


### Sample Output #3

1 2 3 4 5
```### Sample Input #4

None

Sample Output #4

6
```### Sample Input #5

None


### Sample Output #5

7
```### Sample Input #6

None

Sample Output #6

1 2 3 4 5 6 7

Notes/Hints

Constraints

  • $1 \leq N \leq 10000$
  • $1 \leq |S_i|, |T| \leq 20$ (where $ |A| $ denotes the length of string $ A $)
  • $ S_i $ consists of lowercase English letters or ?.
  • $ T $ consists of lowercase English letters.

Scoring

Subtask 1 \[ $ 130 $ points \]

  • There are no invisible parts in the list.

Subtask 2 \[ $ 120 $ points \]

  • No additional constraints.

Sample Explanation 2

If ?o?r?s? is tourist and ?et? is petr, the order would be e, petr, tourist, so e is in the 1st position. If ?o?r?s? is aobrcsd and ?et? is petr, the order would be aobrcsd, e, petr, so e is in the 2nd position. If ?o?r?s? is aobrcsd and ?et? is dete, the order would be aobrcsd, dete, e, so e is in the 3rd position. Therefore, all positions are possible.

Sample Explanation 3

Note that if there are multiple people with the same name, any position is possible.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 tourist petr e
样例输出
1