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

Phone Numbers

Diamond III 다이아몬드 III
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Bessie has a new cell phone with nine buttons, laid out as follows:

123
456
789

Bessie is trying to type out a given phone number in a hurry, so she decides to
save time by pressing multiple buttons at the same time with one of her hooves.
Specifically, Bessie's hoof might press a single digit, two digits that share a
side (for twelve possible pairs in total), or four digits that form a square
(1245, 2356, 4578, or 5689).

For example, if the phone number Bessie is trying to type is 123659874, she
might attempt to save time by

  1. Pressing 1 and 2 at the same time.
  2. Pressing 3.
  3. Pressing 6, 5, 9, and 8 at the same time.
  4. Pressing 7 and 4 at the same time.

Unfortunately, Bessie drastically overestimated her skill at performing this
task - if Bessie's hoof pressess multiple buttons at the same time, then all of
the digits will be typed in arbitrary order. So if Bessie attempts the above
sequence of presses, she may end up typing 123596847 or 213659874 instead (or
one of many other possibilities).

Given a sequence of digits that Bessie has typed, count the number of phone
numbers that she could have been trying to type modulo \(10^9+7\).

*Note: the time limit for this problem is 4s, twice the default.*

Problem credits: Nick Wu

제약

SCORING

  • In inputs 2-3, all phone numbers have length at most \(8\).
  • In inputs 4-5, the phone number only contains 1, 2, and 3.
  • In inputs 6-7, the phone number doesn't contain the digit 5.
  • In inputs 8-9, the phone number only contains 5, 6, 8, and 9.
  • In inputs 10-12, the sum of the string lengths does not exceed \(10^2\).
  • In inputs 13-15, the sum of the string lengths does not exceed \(10^3\).
  • In inputs 16-18, the sum of the string lengths does not exceed \(10^4\).
  • In inputs 19-21, no additional constraints.

Problem credits: Nick Wu

입력 형식

The first line contains \(T\) (\(1\le T\le 10\)), the number of independent test
cases to solve.

The next \(T\) lines each contain a nonempty string of the digits 1 through 9. It
is guaranteed that the total length of these strings does not exceed \(10^5\).

출력 형식

For each test case, the number of phone numbers Bessie might have been trying to
type modulo \(10^9+7\).

예제 1
입력
5
1478
4455
5968
31313211
123659874
출력
5
2
24
3
255
설명

For the first case, Bessie might be trying to type any of the following five
phone numbers:

1478
1487
4178
4187
1748

For example, if Bessie was trying to type 4187, she might have tried pressing 1
and 4 at the same time and then tried pressing 7 and 8 at the same time.

For the third case, as the numbers form a square, Bessie might have been trying
to type any permutation of the input sequence.

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2021-2022 > February > Platinum

태그

평가 및 의견

Phone Numbers

개요
출제자 난이도 Diamond III 다이아몬드 III 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Phone Numbers

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