問題一覧 > 通常問題

No.1908 Assault for Keys

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 169
作問者 : chineristAC / テスター : tokusakurai Kanten4205
お気に入りにしたユーザー ProblemId : 6935 / 自分の提出
問題文最終更新日: 2022-04-05 23:07:48
Assault for Keys
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
yukicoder contest 340 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。