| ASU Coding Cup 11 |
|---|
| Finished |
SpongeBob has failed his boating exam more times than anyone in Qa3 El-Hamoor can count. Patrick suggested he try Jordan instead, because he heard licenses are easy to get there. SpongeBob got excited and packed for Aqaba (LOL). Squidward, being the smart one, followed him to break the news: getting a license in Jordan is actually much harder, and there is a special test every boat rider must pass first. He handed SpongeBob a slip of paper with a formula on it. If SpongeBob can compute the string it describes, Squidward will let him keep heading to Shat El-Ghandoor. Help him out, because we all know he is going to need it.
A formula is a string composed of:
The expansion of a formula is defined as follows:
Important: $$$X$$$ is expanded once and then repeated. So in 3[ab!cd], the inner ab!cd first becomes cd, then is repeated three times to give cdcdcd.
A single line containing the formula $$$s$$$. It is guaranteed that:
Print the expansion of $$$s$$$ on a single line.
2[2{2(a)}]
a; a; , a; a; a; a; , a; a;
5[ab!cd]
cdcdcdcdcd
2[3[a]!b]c!d
d
2{ab!cd}
cd, cd
1[1{1{ya}1{markeb}1{rayeh}1{alagabah}}]
yamarkebrayehalagabah
In Example 1, 2(a) expands to a; a; (two copies of a, each followed by ; ). Then 2{2(a)} joins two such strings with , between them, giving a; a; , a; a; . Finally 2[2{2(a)}] concatenates that with itself two times.
In Example 3, the outer 2[...] first builds 3[a] into its accumulator as aaa, then the inner ! wipes that, then b is added. The inner expansion is therefore b, repeated twice gives bb. At the root level the buffer becomes bb, then c makes it bbc, then the root ! wipes the whole root buffer, then d is appended. Output: d.
| Name |
|---|


