Logo
(追記) (追記ここまで)

28010번 - LaLa and Divination Magic 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 1024 MB184422.222%

문제

$\color{blue}{\text{LaLa}}$ specializes in divination $\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}}$.

Let's say there are $M$ events $E_0, \cdots, E_{M-1}$ that $\color{blue}{\text{LaLa}}$'s interested in forecasting. Each event is associated with one of two outcomes: catastrophe or salvation.

With a single use of $\color{blue}{\text{LaLa}}$'s divination $\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}},ドル $\color{blue}{\text{LaLa}}$ obtains the knowledge of one of the following four forms:

  1. $\mathrm{Knowledge}(i,j,1)$: either $E_i$ is catastrophe or $E_j$ is catastrophe (possibly both).
  2. $\mathrm{Knowledge}(i,j,2)$: either $E_i$ is salvation or $E_j$ is catastrophe (possibly both).
  3. $\mathrm{Knowledge}(i,j,3)$: either $E_i$ is catastrophe or $E_j$ is salvation (possibly both).
  4. $\mathrm{Knowledge}(i,j,4)$: either $E_i$ is salvation or $E_j$ is salvation (possibly both).

$\color{blue}{\text{LaLa}}$ cast her $\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}}$ several times, possibly 0, and wrote down all $M$-tuples of the outcomes of events that are consistent with her knowledge: this is called the result of the forecasting. And then, $\color{blue}{\text{LaLa}}$ fell asleep.

When $\color{blue}{\text{LaLa}}$ woke up, she found out that her pet, $\color{brown}{\text{Leo}},ドル ruined all the predictions of her $\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}}$. Though $\color{blue}{\text{LaLa}}$ was able to find the result of her forecasting, she is unsure if that data was ruined by $\color{brown}{\text{Leo}}$ as well.

Write a program that determines whether there exists a set of predictions of $\color{blue}{\text{LaLa}}$'s $\color{red}{\text{m}} \color{brown}{\text{a}} \color{orange}{\text{g}} \color{blue}{\text{i}} \color{magenta} {\text{c}}$ whose result of the forecasting matches the one $\color{blue}{\text{LaLa}}$ has, and finds a possible set of predictions if there is one.

입력

The input is given in the following format:

$N$ $M$

$S_0$

$S_1$

$\vdots$

$S_{N-1}$

where $N$ is the number of outcomes in the result, $M$ of events, and $S_i$ is a binary string of length $M$ where $j$-th character is '1' if and only if the $i$-th result forecasts that $j$-th event will be in salvation.

The input satisfies the following constraints:

  • $N$ and $M$ are integers.
  • 1ドル \le N, M \le 2,000円$
  • $S_i \ne S_j$ for all integers 0ドル \le i < j < N$.

출력

If there is no such prediction, the output should be a single integer $-1$.

Otherwise, the output should be in the following format:

$K$

$I_0$ $J_0$ $t_0$

$I_1$ $J_1$ $t_1$

$\vdots$

$I_{K-1}$ $J_{K-1}$ $t_{K-1}$

where $K$ is the size of a possible set $S$ of predictions, and, for each 0ドル \le i < K,ドル $S$ contains the prediction $\mathrm{Knowledge}(I_i,J_i,t_i)$.

The output should satisfy the following constraint:

  • 0ドル \le K \le 2\cdot M^2$

It can be proved that if there is such a set of predictions, there also is one satisfying the constraint.

제한

예제 입력 1

2 1
1
0

예제 출력 1

0

예제 입력 2

3 3
101
011
111

예제 출력 2

6
0 2 3
0 1 4
0 2 4
1 2 3
1 2 4
2 2 4

노트

출처

Camp > Osijek Competitive Programming Camp > Winter 2023 > Day 9: Magical Story of LaLa G번

  • 문제를 만든 사람: aeren
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /