## TSOC '15 Contest 2 #1 - The Code

View as PDF

Points: 5
Time limit: 2.0s
Memory limit: 256M

Authors:
Problem type

The students notice several sketchy papers on Mr. Venom's desk, each containing integers. "A code!" Tom cries. "But how do we crack it?" replies Alex. They then see some instructions on a sticky note on one of Mr. Benum's computer monitors:

Why do they keep making me use these stupid codes?! Note to self: Start at the first integer on the paper, then skip ahead positions (or behind, if is negative). The integer you land on decodes to an uppercase alphabetic character . Move to the next integer after the one you just decoded and skip ahead (or behind if is negative) spaces from there. Repeat until you (at any point) move to a , at which point the program should terminate immediately. Hey, at least you will always skip to a position that's actually on the page, and there will always be a number after that. Who even designed this stupid code?

#### Input Specification

The first line of input consists of integer , the number of integers on the paper. The next lines of input contain the integers on the paper in order.

#### Output Specification

The output is the decoded message in uppercase.

9
2
22
5
-2
10
12
0
9
-3

EVIL

#### Explanation of Sample Output 1

You first skip forwards by from the first integer on the page. The decodes to an E. The next number after is , so you skip backwards from there, landing on the which decodes to a V. The next integer is a , so you skip forward by to , which decodes to I. You then skip backward by from , landing on a , which decodes to L. The next number is , so the program terminates.

20
9
1
4
12
4
0
3
1
5
11
-10
16
5
16
-3
14
-9
5
-14
0

#### Sample Output 2

KIDNAPPED

• commented on Sept. 7, 2017, 11:10 a.m.

RTE ? can someone tell me why my program raises the bad_alloc error

• commented on Sept. 7, 2017, 11:21 a.m.

The message terminates when it lands on a zero. There is one case where this happens that you did not consider.