No.2911 Axioms of Topology
Problem Statement
A string consisting only of the digits $0$ and $1$ is called a bit string.
The input gives $2$ positive integers $N, M$ and a set $S$ with $M$ elements, consisting only of bit strings of length $N$.
$S$ is said to be a good set of bit strings if it satisfies all of the following $3$ conditions:
- The string of length $N$ consisting only of the digit $1$ belongs to $S$.
- For any elements $s_0, s_1$ of $S$, the bitwise AND of $s_0$ and $s_1$ belongs to $S$.
- For any subset $S'$ of $S$, the bitwise OR of all elements of $S'$ belongs to $S$.
Here, in condition 3, the bitwise OR of all elements of $S'$ means the unique string $s$ of length $N$ consisting only of the digits $0$ and $1$ such that the following $2$ conditions hold for any positive integer $n$ not greater than $N$:
- If the $n$-th character from the right of $s$ is $1$, then there exists an element $s'$ of $S'$ whose $n$-th character from the right is $1$.
- If the $n$-th character from the right of $s$ is $0$, then there does not exist an element $s'$ of $S'$ whose $n$-th character from the right is $1$.
Determine whether $S$ is a good set of bit strings.
Background
Let $I_N$ be the set of all positive integers not greater than $N$, for each $s \in S$ let $U_s$ be the set of all $i \in I_N$ satisfying the condition "the $i$-th character from the right of $s$ is $1$", and let $\mathcal{O}_S$ be the family of sets $\{U_s \mid s \in S\}$. In this way, $S$ can be translated into the family $\mathcal{O}_S$ of subsets of $I_N$.
When geometry is formulated in modern set theory, the concept of a topological space is often used. The pair $(I_N,\mathcal{O}_S)$ is a topological space if and only if it satisfies all of the following $3$ conditions:
- $I_N$ belongs to $\mathcal{O}_S$.
- For any elements $U_0, U_1$ of $\mathcal{O}_S$, $U_0 \cap U_1$ belongs to $\mathcal{O}_S$.
- For any subset $\mathcal{U}$ of $\mathcal{O}_S$, $\bigcup_{U \in \mathcal{U}} U$ belongs to $\mathcal{O}_S$.
Therefore, by definition, this condition is equivalent to $S$ being a good set of bit strings. In other words, this problem is equivalent to determining whether $(I_N,\mathcal{O}_S)$ is a topological space.
Input
Number the elements of $S$ by the positive integers $m$ not greater than $M$, and denote them by $s_m$.
Then, the input is given from Standard Input in $1 + M$ lines in the following format:
- On line $1$, $N, M$ are given, separated by a half-width space.
- For each positive integer $m$ not greater than $M$, $s_m$ is given on line $1 + m$.
$N$ $M$ $s_1$ $\vdots$ $s_M$
Constraints
The input satisfies the following constraints:
- $N$ is an integer satisfying $1 \leq N \leq 16$
- $M$ is an integer satisfying $1 \leq M \leq \min \{2^N,2^{12}\}$
- For any positive integer $m$ not greater than $M$, $s_m$ is a string of length $N$ consisting only of the digits $0$ and $1$
Output
Print Yes if $S$ is a good set of bit strings, and No otherwise.
Print a newline at the end.
Sample
Sample 1
Input
1 1 0
Output
No
$S = \{0\}$ does not satisfy condition 1. Indeed, $S$ has no element other than $0$, and the string $0$ is not a string consisting only of the digit $1$.
Also, $(I_N,\mathcal{O}_S) = (\{1\},\{\{\}\})$. Since $I_N \notin \mathcal{O}_S$, $(I_N,\mathcal{O}_S)$ is not a topological space.
Sample 2
Input
1 1 1
Output
No
$S = \{1\}$ does not satisfy condition 3. Indeed, if the subset $S'$ of $S$ is taken to be the empty set, its bitwise OR is $0$, but $0$ does not belong to $S$.
Also, $(I_N,\mathcal{O}_S) = (\{1\},\{\{1\}\})$. Letting $\mathcal{U} := \{\}$, we have $\mathcal{U} \subset \mathcal{O}_S$, but $\bigcup_{U \in \{\}} U = \{\} \notin \mathcal{O}_S$, so $(I_N,\mathcal{O}_S)$ is not a topological space.
Sample 3
Input
1 2 0 1
Output
Yes
$S = \{0,1\}$ satisfies all of conditions 1,2,3, so it is a good set of bit strings.
Also, $(I_N,\mathcal{O}_S) = (\{1\},\{\{\},\{1\}\})$. For those who know topological spaces, $(I_N,\mathcal{O}_S)$ is both a discrete space and an indiscrete space. For those who know algebraic geometry, $(I_N,\mathcal{O}_S)$ is a topological space homeomorphic to the affine scheme $\textrm{Spec}(\mathbb{Q}_p)$ associated with the field $\mathbb{Q}_p$ of $p$-adic numbers.
Sample 4
Input
3 4 000 011 110 111
Output
No
$S = \{000,011,110,111\}$ does not satisfy condition 2. Indeed, $011$ and $110$ are elements of $S$, but their bitwise AND $010$ does not belong to $S$.
Also, $(I_N,\mathcal{O}_S) = (\{1,2,3\},\{\{\},\{2,3\},\{1,2\},\{1,2,3\}\})$. $\{2,3\}$ and $\{1,2\}$ are elements of $\mathcal{O}_S$, but $\{2,3\} \cap \{1,2\} = \{1\} \notin \mathcal{O}_S$, so $(I_N,\mathcal{O}_S)$ is not a topological space.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。