NABILHACKER - Hack the Password

no tags 

Many people asked me what actually contest programming do in real life projects. That does not feel so interesting to me. What I found interesting is, one day a hacker friend came to me. He asked me to solve one of his hacking problems.

When you try to steal someone's password, you may set a keylogger in his/her computer. Keylogger will give you a string that is typed as the password. But there is a problem, it will give you everything victim typed such as left key, right key, backspace everything. (Left key and right key means the keys you use to play car games, and backspace is the key you use to remove a letter, the button on the top of "Enter" button. )

Suppose, the victim typed "generio312" as password, but he follows these criteria:

1. he typed generio1.

2. Then he pressed the left key, and press 3. So the password will be generio31.

3. Then he pressed the right key and press 2. So the password will be generio312.

4. Now he typed ghj and then press backspace three times and remove these three letters. So the final password is generio312.

But, as I said, keylogger gives you all the typed key. You will get "generio1<3>2ghj---". (Here, < for left key, > for right key and - for backspace.)


At first input T, the number of test cases.
Then input T strings. 1<=|s|<=10^6. The strings will include upper case, lower case, <, >, - and digits(0-9).


The output should contain a string each line, the password.









hide comments
Boopathi Rajaa: 2018-12-21 02:46:18

I'm using Go and TLE for O(n).

dewa251202: 2018-10-03 10:01:33

i love stack <3

yasirnabil: 2018-10-02 21:12:53

@kaushalag29 O I found your solution. insert and erase in vectors take O(n) complexity, so your complexity is technically O(n^2) (I assume). Instead of insert and delete, please try to use push_back and pop_back.

yasirnabil: 2018-10-02 20:59:36

@kaushalag29 Which one is your solution? O(n) must get AC.

yasirnabil: 2018-10-02 20:54:27

@lolipop98 Yes.

lollipop98: 2018-09-29 12:09:45

Do we assume that ">>" (right key) at the START of an expression are redundant as in most textfields these days??

kaushalag29: 2018-09-29 11:07:12

@Nabil: O(n) gives TLE?What is the expected time complexity?

Added by:Nabil
Time limit:2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)