問題一覧 > 通常問題

No.438 Introduction to Cww Programming

レベル : / AI推定難易度 : 1200 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 82
作問者 : btk / テスター : 🍡yurahuna
お気に入りにしたユーザー ProblemId : 1100 / 自分の提出
問題文最終更新日: 2026-06-26 18:20:42
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. Back to the original
yukicoder contest 152 (順位表) の他の問題:

Problem Statement

There is a programming language called Cww.
A Cww source code is executable when it satisfies the following conditions.

・ The source code consists only of the 4 kinds of characters 'c','w','C','W'.
・ The source code consists of a single-line string (a newline is required at the end).

Let $S$ be an executable Cww source code (string).
The Cww executor takes $S$ as input and operates as follows.

(Reference: Wikipedia Stack)
・ The Cww executor has a stack. The stack initially contains $0$ elements.
・ Let $S_i$ be the $i$-th character of $S$. The executor reads $S_1,S_2,,,$ in order from left to right.
・ When the program reads the character 'c', the integer $x$ is added to the top of the stack.
・ When the program reads the character 'w', the integer $y$ is added to the top of the stack.
・ Let $a$ be the $1$st element from the top of the stack and $b$ be the $2$nd element from the top of the stack. When the program reads the character 'C', it removes $a,b$ from the stack and adds $a + b$ to the top of the stack.
・ Let $a$ be the $1$st element from the top of the stack and $b$ be the $2$nd element from the top of the stack. When the program reads the character 'W', it removes $a,b$ from the stack and adds $a - b$ to the top of the stack.
・ When there are no more characters for the program to read, the program removes the integer $z$ at the top of the stack, outputs $z$, and terminates.
・ When the program removes an element from the stack, if the stack is empty, the program results in an error (WA) and terminates. Note that reading 'C' or 'W' removes 2 elements from the stack.

Now, cww, a beginner at Cww, is writing a program in Cww that outputs a certain integer $z$.
Given integers $x,y,z$, create for cww one Cww source code that outputs $z$.
However, since cww is a beginner, source code that is too long cannot be read.
Therefore, the source code you output must be at most $10000$ characters, excluding the newline.
If it is impossible in any way to output $z$ within $10000$ characters, output the string "NO" on one line.

Input

$x$ $y$ $z$

$0 \le x,y,z \le 100000000$

Output

$S$

$S$ must be a Cww source code that outputs $z$, with $1 \le |S| \le 10000$.
If no source code that outputs $z$ can be constructed, output ”NO” on one line.
Except for the ”NO” case, outputting any character other than ’c’,’w’,’C’,’W’ in $S$ results in an error.

Print a newline at the end.

Sample

Sample 1
Input
1 2 3
Output
cwC

When the source code is "cwC", the program operates as follows.
[ ] ... stack
'c' : add $x=1$ to the stack [1]
'w' : add $y=2$ to the stack [12]
'C' : remove $2,1$ from the stack and add $2+1 = 3$ [3]
Therefore, the source code "cwC" outputs the 3 remaining on the stack.

"wcC", "wwCcWccWW", and others are also correct.

Sample 2
Input
2 3 7
Output
cwwCwCW

When the source code is "cwwCwCW", the program operates as follows.
[ ] ... stack
'c' : add $x=2$ to the stack [2]
'w' : add $y=3$ to the stack [23]
'w' : add $y=3$ to the stack [233]
'C' : remove $3,3$ from the stack and add $3+3 = 6$ [26]
'w' : add $y=3$ to the stack [263]
'C' : remove $3,6$ from the stack and add $3+6 = 9$ [29]
'W' : remove $9,2$ from the stack and add $9-2 = 7$ [7]
Therefore, the source code "cwwCwCW" outputs the 7 remaining on the stack.

Sample 3
Input
42 72 88
Output
NO

Under the constraints, no correct source code can be created,
so output "NO" instead.

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