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

Moo Decomposition

Platinum V 플래티넘 V
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

You have a long string \(S\) of Ms and Os and an integer \(K \geq 1\). Count the
number of ways of ways to decompose \(S\) into subsequences such that each
subsequence is MOOOO....O with exactly \(K\) Os, modulo \(10^9+7\).

Since the string is very long, you are not given it explicitly. Instead, you are
given an integer \(L\) (\(1 \leq L \leq 10^{18}\)), and a string \(T\) of length \(N\)
(\(1 \leq N \leq 10^6\)). The string \(S\) is the concatenation of \(L\) copies of the
string \(T\).

Problem credits: Dhruv Rohatgi

제약

SCORING

  • Inputs 5-7: \(K=1\), \(L = 1\)
  • Inputs 8-10: \(K=2\), \(N\leq 1000\), \(L = 1\)
  • Inputs 11-13: \(K=1\)
  • Inputs 14-19: \(L = 1\)
  • Inputs 20-25: No additional constraints.

Problem credits: Dhruv Rohatgi

입력 형식

The first line contains \(K\), \(N\), and \(L\).

The second line contains the string \(T\) of length \(N\). Every character is either
an M or an O.

It is guaranteed that the number of decompositions of \(S\) is nonzero.

출력 형식

Output the number of decompositions of string \(S\), modulo \(10^9+7\).

예제 1
입력
2 6 1
MOOMOO
출력
1
설명

The only way to decompose \(S\) into MOOs is to let the first three characters form a MOO and
the last three characters form another MOO.

예제 2
입력
2 6 1
MMOOOO
출력
6
설명

There are six distinct ways to decompose the string into subsequences (uppercase
letters form one MOO, lowercase letters form another):

  • MmOOoo
  • MmOoOo
  • MmOooO
  • MmoOOo
  • MmoOoO
  • MmooOO
예제 3
입력
1 4 2
MMOO
출력
4
예제 4
입력
1 4 100
MMOO
출력
976371285
설명

Make sure to take the answer modulo \(10^9+7\).

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2024-2025 > US Open > Gold

태그

평가 및 의견

Moo Decomposition

개요
출제자 난이도 Platinum V 플래티넘 V 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Moo Decomposition

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