luogu#P9087. 「SvR-2」音符

    ID: 7176 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>洛谷原创Special Judge构造洛谷月赛

「SvR-2」音符

Problem Description

In this problem, “substring” means:

If there is a segment of continuous characters in a string ss that forms a string pp, then pp is a substring of ss.

We use a string to represent a sheet music score, and use a character to represent each note.

We define an “accent” as the occurrence of two consecutive identical characters in the sheet music. For example, there are 44 “accents” in eeeee\tt eeeee.

Now Sept is going to write a sheet music of length nn for Tpes to see. His evaluation rules are as follows:

  • Each time an “accent” appears in the sheet music, his anger value increases by aa.
  • For each substring of length kk that contains no “accent”, his anger value increases by bb.

Given n,k,a,bn,k,a,b, please help Sept construct a sheet music such that Tpes’s anger value xx is minimized.

Input Format

This problem has multiple test cases.

The first line contains an integer TT, indicating the number of test cases.

The next TT lines each contain four integers n,k,a,bn,k,a,b, with meanings as described in the statement.

Output Format

Output a total of 2T2 \cdot T lines. For each test case, output two lines:

  • Line 1: Tpes’s minimum anger value xx.
  • Line 2: The sheet music you constructed.
2
4 5 2 2
8 6 3 2
0
Sept
3
2023yyds

Hint

Constraints and Notes

This problem uses bundled testdata.

Subtask\bf{Subtask} n\bm{n\le} n\bm{\sum n\le} T\bm{T\le} Score\bf{Score}
1\sf 1 66 1010 33 10\tt 10
2\sf 2 10310^3 2×1032\times 10^3 No special limit 30\tt 30
3\sf 3 No special limit 60\tt 60

For 100%100\% of the testdata, 2T1002\le T\le 100, 2n,k1052\le n,k\le 10^5, 1a,b1091\le a,b\le 10^9. Within a single test case, it is guaranteed that n2×105\sum n\le 2\times 10^5.

Output Notes

Outputting xx and constructing the sheet music can be considered as two separate subtasks. If you can only finish one of them, please use a valid character or number as a placeholder in the position corresponding to the other subtask.

You may output any characters in the sheet music, including digits, uppercase and lowercase letters, etc., but spaces are not allowed.

Special Judge Return Message Explanation

This problem uses a Special Judge to determine whether your answer is correct.

checker.cpp will return messages in the form Score=A,Type=B\texttt{Score=}\text A,\texttt{Type=}\text B.

The Score\tt Score category indicates your scoring status. A\text A can take the following values:

  • A=1\text A=1, meaning:
    $\text{Accepted.} \texttt{ Your Ans and SM are both proper.}$
    This means all TT answers meet the requirements.
  • A=2\text A=2, meaning:
    $\text{Partially Correct.}\texttt{ All Ans are right.}$
    This means in this test point, all your reported xx are correct, and you can get 20%20\% of the score for this test point.
  • A=3\text A=3, meaning:
    $\text{Partially Correct.}\texttt{ You pass 70\% tests!}$
    This means in this test point, the number of test cases you answered correctly is at least 0.7×T\lfloor0.7\times T\rfloor (both xx and the sheet music meet the requirements), and you can get 10%10\% of the score for this test point.
  • A=4\text A=4, meaning you can only get 00 points for this test point.

The Type\tt Type category indicates your error type. B\text B can take the following values:

  • B=0\text B=0, meaning all your answers are correct, paired with A=1\text A=1.
  • B=1\text B=1, meaning:
    $\text{Wrong Answer.}\texttt{ The length of your SM is not right!}$
    This means in one test case, the length of the sheet music you constructed is not nn.
  • B=2\text B=2, meaning:
    $\text{Wrong Answer.}\texttt{ Your Ans is not right!}$
    This means in one test case, the value of xx you output is wrong.
  • B=3\text B=3, meaning:
    $\text{Wrong Answer.}\texttt{ Your Ans and SM are not matched!}$
    This means in one test case, the anger value produced by your constructed sheet music is not xx.

Here, Ans, SM\text{Ans, SM} stand for Answer (the value of xx) and Sheet Music (the sheet music).

Note that Type\tt Type only reflects the type of the first error in this test point.

Translated by ChatGPT 5