DMOPC '16 Contest 3 P2 - Starstruck Squeeze

View as PDF

Points: 8 (partial)
Time limit: 1.0s
Memory limit: 128M

Authors:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

jackyliao123 is part of the robotics team in his school. During one of the meetings after school, a sketchy person was wandering around and came into the robotics room. This person sees a storage bin full of the VEX Starstruck jacks and immediately becomes obsessed with them. Phoenix1369 sees this and tells him that he can disassemble one of the jacks by squeezing them. The person does so, and the jack breaks into pieces.

Due to the sketchy nature of this person and his obsession with the jacks, he begins to take jacks from the storage bin one by one, and squeezing them. This frenzied period continues for seconds.

Every second, the person does one of two possible actions:

• T: Takes one jack out from the storage bin, and places it on the table.
• B q: Breaks each jack or piece that's currently on the table into q pieces, and puts them on the floor. When the table is empty, transfer all the pieces on the floor back onto the table.

jackyliao123 needs to gather all these pieces so that he can fix them by gluing them together at home. After a few minutes, he realizes that the number of pieces is growing rapidly. In order to prevent integer overflow allow jackyliao123 to finish the work that was assigned by his English teacher, he decides that he will consider a jack "dust" if the jack is broken into strictly greater than pieces, and he will not be gluing them back together.

jackyliao123 needs to figure out how many pieces each jack has been broken into, to assist him in gluing together the jacks that the person broke.

Since jackyliao123 is quite busy building the robot, can you help him figure this out?

Input Specification

The first line will contain the integers , and , representing the number of modifications done by the sketchy person, the number of jacks in the storage bin, and the dust threshold respectively.

The next lines represent the operations. Each line will contain either just a character T, or a character followed by an integer B q, where is the integer.

, for each

Output Specification

Output the number of pieces each jack has been broken into, in the order they were taken out of the storage bin.

If a jack has been considered as dust, output dust.

Sample Input

7 4 5
T
T
B 2
B 3
T
B 4
T

Sample Output

dust
dust
4
1

Explanation

The person did operations on the jacks that were in the storage bin, and jackyliao123 will consider any jacks that got broken up into more than pieces as "dust".

1. The person takes out a jack from the bin and puts it on the table.
2. He takes out another jack. (Same operation as above)
3. He breaks each of the 2 jacks into 2 pieces, resulting in broken pieces for the first jack and broken pieces for the second jack.
4. He then breaks each piece into 3 new pieces, resulting in broken pieces for the first jack and broken pieces for the second jack.
5. He takes out another jack.
6. He then breaks each piece into 4 new pieces, resulting in broken pieces for the first jack, broken pieces for the second jack, and 4 broken pieces for the third jack.
7. He takes out another jack.

In the end, he took out 4 jacks, the first 2 were broken into pieces each and therefore considered as "dust" by jackyliao123. The third jack was broken into pieces, and the fourth jack was not broken, therefore it remains as piece.

• commented on Nov. 15, 2018, 9:54 p.m.

Why am I getting IR???

• commented on April 11, 2017, 5:44 p.m.

Why am I MLEing?

• commented on April 12, 2017, 5:56 p.m.

I'm not sure but I think it's due to your product function. My guess is that as N gets really large, you're essentially performing something along the lines of a manual factorial or exponent function and storing all the steps.

• commented on Dec. 15, 2016, 11:23 p.m.

If the table becomes empty while breaking the pieces, do I move the pieces from the floor to the table?

• commented on Dec. 16, 2016, 12:40 a.m.

Don't worry about the floor thing. Just assume that the pieces stay on the table at all times. Don't move anything to the floor.

• commented on Dec. 14, 2016, 9:35 p.m.

card[] overflows in your latest 5/10 submission.

• commented on Dec. 14, 2016, 3:15 a.m.

Currently only 1 python submission has passed with question in time(from the mighty D). Would it be possible to get a time extension for python

• commented on Dec. 14, 2016, 1:42 p.m.

It wasn't an issue with the language. Your solution's time complexity is too slow for the constraints.

• commented on Dec. 15, 2016, 1:47 a.m.

I know realise that, thank you

• commented on Dec. 14, 2016, 2:55 a.m. edit 5

When I hover over the PyPy2 button it changes location to the top of the 7'th column and when I move my mouse away it moves back to the bottom of the 6'th column

EDIT:I managed to click it by messing around with jQuery

EDIT 2:This applies to all languages in the bottom row