No.1908 Assault for Keys
タグ : / 解いたユーザー数 169
作問者 :
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
Problem Statement
chinerist has been imprisoned in yuki Prison for the crime of coding with an indent width of 1.
In yuki Prison there are $N$ guards $i\ (1\le i \le N)$, and each guard holds some of the $M$ types of keys $j\ (1\le j \le M)$.
Which keys guard $i$ holds is represented by a string $S_i=S_{i1}S_{i2}\dots S_{iM}$ of length $M$ consisting only of o,x: $S_{ij}=$o means that guard $i$ holds key $j$, and $S_{ij}=$x means that guard $i$ does not hold key $j$.
Each key $j\ (1\le j \le M)$ is held by $1$ or more guards.
To escape from yuki Prison, at least $1$ of each of the $M$ types of keys is required. chinerist has decided to collect keys by assaulting some of the guards and robbing each of them of all the keys they hold.
Find the minimum integer $K$ that satisfies the following condition.
Condition- No matter which $K$ of the $N$ guards are assaulted, at least $1$ of each of the $M$ types of keys can be obtained.
Input
$N$ $M$ $S_1$ $S_2$ $\vdots$ $S_N$
- $1 \le N \le 1000$
- $1 \le M \le 1000$
- $S_i$ is a string of length $M$ consisting only of
o,x - For each $j\ (1\le j \le M)$, there exists at least 1 $i$ such that $S_{ij}=$
o
Output
Output the answer.
Print a newline at the end.
Sample
Sample 1
Input
3 3 oxo xoo oox
Output
2
If only guard $1$ is assaulted, key $2$ cannot be collected.
If guards $1,\ 2$ are assaulted, all $3$ types of keys are collected.
There are $2$ other ways to assault $2$ guards, namely assaulting guards $2,\ 3$ and assaulting guards $1,\ 3$, and all $3$ types of keys are collected in either way.
Therefore, the minimum $K$ that satisfies the condition is $2$.
Sample 2
Input
10 15 ooxxxxooooxoxox ooxxxooxooxxxxx ooooooxooooxxxx oxxoxooxoxoooxx oxooooxoooooxoo ooooxoxooooxxox oxooxoxoooxxxxx ooxoxoxoooooxoo oooxoooxooxooxo oxoxxoxooooxoxx
Output
8
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。