#abc358c. C - Popcorn
C - Popcorn
Score : points
问题陈述
在AtCoder Land,有个爆米花摊位,编号从到。它们有种不同的爆米花口味,标记为,但并不是每个摊位都出售所有口味的爆米花。
高桥获得了关于每个摊位出售哪些口味爆米花的信息。这些信息由个长度为的字符串表示。如果的第个字符是o
,这意味着摊位出售第种口味的爆米花。如果是x
,则意味着摊位不出售第种口味的爆米花。每个摊位至少出售一种口味的爆米花,每种口味的爆米花至少在一个摊位出售。
高桥想要尝试所有口味的爆米花,但不想走太多路。确定高桥需要访问的最少摊位数量,以购买所有口味的爆米花。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
In AtCoder Land, there are popcorn stands numbered to . They have different flavors of popcorn, labeled , but not every stand sells all flavors of popcorn.
Takahashi has obtained information about which flavors of popcorn are sold at each stand. This information is represented by strings of length . If the -th character of is o
, it means that stand sells flavor of popcorn. If it is x
, it means that stand does not sell flavor . Each stand sells at least one flavor of popcorn, and each flavor of popcorn is sold at least at one stand.
Takahashi wants to try all the flavors of popcorn but does not want to move around too much. Determine the minimum number of stands Takahashi needs to visit to buy all the flavors of popcorn.
Constraints
- and are integers.
- Each is a string of length consisting of
o
andx
. - For every , there is at least one
o
in . - For every , there is at least one such that the -th character of is
o
.
Input
The input is given from Standard Input in the following format:
Output
Print the minimum number of stands Takahashi needs to visit to buy all the flavors of popcorn.
Sample Input 1
3 5
oooxx
xooox
xxooo
Sample Output 1
2
By visiting the 1st and 3rd stands, you can buy all the flavors of popcorn. It is impossible to buy all the flavors from a single stand, so the answer is .
Sample Input 2
3 2
oo
ox
xo
Sample Output 2
1
Sample Input 3
8 6
xxoxxo
xxoxxx
xoxxxx
xxxoxx
xxoooo
xxxxox
xoxxox
oxoxxo
Sample Output 3
3