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

HILO

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

의견: 0

설명

Bessie knows a number \(x+0.5\) where \(x\) is some integer between \(0\) to \(N,\)
inclusive (\(1\le N\le 5000\)).

Elsie is trying to guess this number. She can ask questions of the form "is \(i\)
high or low?" for some integer \(i\) between \(1\) and \(N,\) inclusive. Bessie
responds by saying "HI!" if \(i\) is greater than \(x+0.5\), or "LO!" if \(i\) is less
than \(x+0.5\).

Elsie comes up with the following strategy for guessing Bessie's number. Before
making any guesses, she creates a list of \(N\) numbers, where every number from
\(1\) to \(N\) occurs exactly once (in other words, the list is a permutation of
size \(N\).) Then, she goes through the list, guessing numbers that appear in the
list in order. However, Elsie skips any unnecessary guesses. That is, if Elsie
is about to guess some number \(i\) and Elsie previously guessed some \(j < i\) such
that Bessie responded with "HI!," Elsie will not guess \(i\) and will move on to
the next number in the list. Similarly, if she is about to guess some number \(i\)
and she previously guessed some \(j > i\) such that Bessie responded with "LO!,"
Elsie will not guess \(i\) and will move on to the next number in the list. It can
be proven that using this strategy, Elsie always uniquely determines \(x\)
regardless of the permutation she creates.

If we concatenate all of Bessie's responses of either "HI" or "LO" into a single
string \(S,\) the number of times Bessie says "HILO" is the number of length \(4\)
substrings of \(S\) that are equal to "HILO."

Bessie knows that Elsie will use this strategy and has already chosen the value
of \(x\), but she does not know what permutation Elsie will use. Your goal is to
compute the sum of the number of times Bessie says "HILO" over all permutations
that Elsie could possibly choose, modulo \(10^9+7\).

Problem credits: Richard Qi

제약

SCORING

  • Test cases 3-10 satisfy \(N\le 50\).
  • Test cases 11-18 satisfy \(N\le 500\).
  • Test cases 19-26 satisfy no additional constraints.

Problem credits: Richard Qi

입력 형식

The only line of input contains \(N\) and \(x\).

출력 형식

The total number of HILOs modulo \(10^9+7\).

예제 1
입력
4 2
출력
17
설명

In this test case, Bessie's number is \(2.5\).

For example, if Elsie's permutation is \((4,1,3,2)\), then Bessie will say
"HILOHILO," for a total of two "HILO"s. As another example, if Elsie's
permutation is \((3,1,2,4)\), then Bessie will say "HILOLO," for a total of one
"HILO."

예제 2
입력
60 10
출력
508859913
설명

Make sure to output the sum modulo \(10^9+7\).

문제 정보

riseoj 작성

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

태그

평가 및 의견

HILO

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

Log in to rate problems.

개별 의견

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

풀이 제출

HILO

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