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

23737번 - Rock Paper Scissors Strategy 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB (추가 메모리 없음)137770.000%

문제

Yunee, the president of UNIST Rock-Paper-Scissors Association, held a rock-paper-scissors contest for UNIST students and gathered $N$ participants.
The contest consists of $M$ games in total. In each game, two or three participants make one of the three hand gestures—rock, paper, or scissors—all at once. Then the winner of each game is determined according to the following rules.

  • Rock wins scissors, scissors win paper, and paper wins rock.
  • If everyone makes the same hand gestures, the game draws.
  • If all three types of hand gestures appear, the game draws.
  • If the game doesn't draw, everyone who makes a winning hand gesture wins.

Each UNIST student had prepared one of the following strategies for this contest.

  • Always play the same hand gesture.
  • Play the three hand gestures once each, in any order. Repeat the same pattern for every three games this player participates in.

Unfortunately, Yunee couldn't watch the contest because of a lot of paperwork. But Yunee has a document that lists the participants and the winners of each game. Yunee wondered what strategies the students might have used. Find the number of possible strategy combinations of all students, modulo 10ドル^9+7$.

입력

The first line contains two integers $N$ and $M$ $(3 \leq N \leq 300, 1 \leq M \leq 300)$. $N$ represents the number of participants of the contest. $M$ represents the number of games.

The next $M$ lines contain the descriptions for the $M$ games in chronological order. Each game is described as follows.

  • The number of participants $a$ is given. $(a=2\text{ or }a=3)$
  • The participants' numbers $p_1, \cdots, p_a$ are given. They are distinct integers ranging from 1ドル$ to $N$.
  • A delimiter / is given.
  • The number of winners $b$ is given. If the game draws, $b = 0$. $(0\leq b < a)$
  • The winners' numbers $q_1, \cdots, q_b$ are given. They are distinct integers among $p_1, \cdots, p_a$.

출력

Output the number of possible strategy combinations of all students, modulo 10ドル^9+7$.

제한

예제 입력 1

3 3
2 1 2 / 1 1
2 2 3 / 1 2
3 1 2 3 / 0

예제 출력 1

27

In the first example, the following combination of strategies is possible, for instance.

  • Student 1 repeats scissors, rock, and then paper.
  • Student 2 always play paper.
  • Student 3 repeats rock, scissors, and then paper.

The game proceeds as follows.

  • In the first game, student 1 plays scissors and student 2 plays paper. Student 1 wins.
  • In the second game, student 2 plays paper and student 3 plays rock. Student 2 wins.
  • In the third game, student 1 plays rock, student 2 plays paper, and student 3 plays scissors. The game draws.

예제 입력 2

3 1
2 1 2 / 0

예제 출력 2

243

예제 입력 3

3 3
2 1 2 / 1 1
2 2 1 / 1 1
2 1 2 / 0

예제 출력 3

0

힌트

출처

University > UNIST > 3rd UNIST Algorithm Programming Contest Uni-CODE 2021 H번

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

출처

대학교 대회

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

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