RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0688

Moo Hunt

Bronze II 브론즈 II
난이도
2s
시간 제한
256MB
메모리 제한
1
맞았습니다!!
1
제출 수
100.0%
정답률
레이팅

의견: 0

설명

Bessie is playing the popular game "Moo Hunt". In this game, there are \(N\)
(\(3 \le N \le 20\)) cells in a line, numbered from \(1\) to \(N\). All cells either
have the character \(M\) or \(O\) with the \(i\)-th cell having character \(s_i\).

Bessie plans to perform \(K\) (\(1 \le K \le 2 \cdot 10^5\)) mooves. On her \(i\)-th
moove, Bessie will tap \(3\) different cells (\(x_{i},y_{i},z_{i}\))
(\(1 \le x_{i},y_{i},z_{i} \le N\)). Bessie will earn a point if \(s_{x_i}=M\) and
\(s_{y_i}=s_{z_i}=O\). In other words, Bessie will earn a point if she forms the
string \(MOO\) by tapping cells \(x_{i},y_{i},z_{i}\) in that order.

Farmer John wants to help Bessie get a new high score. He wants you to find the
maximum possible score Bessie could get across all possible boards if she
performs the \(K\) mooves as well as the number of different boards that will
allow Bessie to achieve this maximum possible score. Two boards are different if
there exists a cell such that the corresponding characters at the cell are
different.

Problem credits: Alex Liang

제약

SCORING

  • Inputs 3-5: \(N \le 8, K \le 10^4\)
  • Inputs 6-12: There will be one test for each \(N \in \{14,15,16,17,18,19,20\}\) with no additional constraints on \(K\).

Problem credits: Alex Liang

입력 형식

The first line contains \(N\) and \(K\), the number of cells and the number of
mooves Bessie will perform.

Each of the next \(K\) lines contains \(x_i, y_i, z_i\) describing Bessie's \(i\)-th
move (\(x_i, y_i, z_i\) are pairwise distinct).

출력 형식

Output the maximum possible score Bessie could achieve, followed by the count of
different boards that will allow Bessie to achieve this maximum score.

예제 1
입력
5 6
1 2 3
1 2 3
1 3 5
2 3 4
5 3 2
5 2 3
출력
4 2
설명

The boards \(MOOOM\) and \(MOOMM\) allow Bessie to achieve a maximum score of \(4\).
In both boards, Bessie will earn points on mooves \(1,2,5,6\). It can be shown
that this is the maximum score Bessie can achieve, and those two boards are the
only possible boards allowing Bessie to achieve a score of \(4\).

예제 2
입력
6 12
2 4 3
2 3 4
3 5 2
3 5 1
3 1 5
3 1 2
6 1 5
1 6 4
2 3 6
3 6 2
4 1 6
3 4 2
출력
6 3
설명

The boards that allow Bessie to achieve a maximum possible score of \(6\) are
\(OOMOOO\), \(OOMMOO\), and \(OOMOOM\).

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2025-2026 > Second Contest > Bronze

태그

평가 및 의견

Moo Hunt

개요
출제자 난이도 Bronze II 브론즈 II 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Moo Hunt

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8