問題一覧 > 通常問題

No.3320 yiwiwiy

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 3
作問者 : 👑 みうね / テスター : ゆにたりー卿 Rice_tawara459 DeltaStruct Andrew8128 のらら elphe leaf_1415 👑 loop0919 👑 seekworser
お気に入りにしたユーザー ProblemId : 12721 / 自分の提出
問題文最終更新日: 2025-10-30 19:43:42
yiwiwiy
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
第2回 岩井星人アンソロジープログラミングコンテスト Div.1 (順位表) の他の問題:

Problem Statement

You have $Y$ copies of the character y, $I$ copies of the character i, and $W$ copies of the character w. By using all of these characters and arranging them in a row in any order, you can create a string $S$ of length $Y + I + W$. Let $P$ be the number of not necessarily contiguous subsequences of $S$ that are equal to yiwiy as strings, and let $Q$ be the number of contiguous substrings of $S$ that are equal to iwiwi as strings. The attractiveness of $S$ is then $AP + BQ$. Here, $A, B$ are non-negative integers given in the input, and $2$ subsequences or substrings are distinguished if and only if the positions from which the characters are taken differ. Find one string $S$ with the highest attractiveness among the strings you can create. If there are multiple candidate answers, you may output any of them.

You are given $T$ test cases; find the answer for each of them.

Constraints

  • $1 \leq T \leq 10^5$
  • $1 \leq Y + I + W \leq 10^6$
  • $0 \leq Y, I, W$
  • $0 \leq A, B \leq 10^9$
  • All input values are integers.
  • The sum of $Y + I + W$ over all test cases is at most $10^6$.

Input

The input is given in the following format.
$T$
$\text{case}_1$
$\text{case}_2$
$\vdots$
$\text{case}_T$

Here, $\text{case}_i$ denotes the input for the $i$-th case. Each case is given in the following format.

$Y\ I\ W\ A\ B$

Output

Output in the following format.
$\text{answer}_1$
$\text{answer}_2$
$\vdots$
$\text{answer}_T$

Here, $\text{answer}_i$ denotes the output for the $i$-th case. Each case is as follows.

Suppose that $S$ is one of the strings with the highest attractiveness among those you can create. Then, output in the following format.

$S$

Sample

Sample 1
Input
3
2 3 2 1 1
1 2 8 100 0
6 6 3 2 5
Output
yiwiwiy
yiwiwwwwwww
yyyiiiwwwiiiyyy

For the $1$st test case, creating the string yiwiwiy achieves an attractiveness of $5$. It is impossible to create a string with attractiveness greater than $5$, so outputting this is correct.

For the $2$nd test case, the attractiveness of yiwiwwwwwww is $0$. It is impossible to create a string with attractiveness $1$ or more, so outputting this is correct. For this input, outputting another string of attractiveness $0$ that satisfies the conditions of the problem, such as wwwwiyiwwww, is also correct.

For the $3$rd test case, the maximum achievable attractiveness is $486$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。