[URI Online Judge] – 2496 – The Only Chance

Link: https://www.urionlinejudge.com.br/judge/en/problems/view/2496

Everyone knows that the decisions that are made make all the difference in the result obtained. A well-known example is the Monty Hall paradox, which consists of three stages, and in the third, the competitor gives the final card and, depending on his choice, may or may not win a car.

You want to get an “Accepted” and for this you will have to write a program that checks if a single position change between two letters will result in an ordered sequence. Consider the following strings:



For the first sequence to be ordered, more than one change is required between the position of the letters. In the second, on the other hand, it is enough that I and J change positions. Its mission is to verify if for each sequence received there is a single exchange between two letters that makes it ordered.


The input is composed of an integer N, which represents the number of test cases (1 <= N <= 100). Each test case consists of an integer M, which represents the number of letters of a sequence (2 <= M <= 26) and an alphabetical sequence composed of M letters. Letters are always uppercase and are not in an index greater than M. If M is 4, the only possible letters for the sequence are: A, B, C, or D in any order.


For each reported sequence, the program must return a single line that will display “There are the chance.” If the sequence obeys the ordering rule mentioned, or “There are not the chance.” Otherwise.

Input SamplesOutput Samples
There are the chance.
There aren’t the chance.



There aren’t the chance.

There are the chance.



[URI Online Judge] – 2495 – Where is my Pen?

Link: https://www.urionlinejudge.com.br/judge/en/problems/view/2495

At the end of last month, I bought a set with N pens. It cost about 1/3 of my allowance, and on account of that, I decided to tell all my friends that I would not lend it to anyone. But last week, my cousin Jean borrowed it, saying she was going to give it back to me the next morning. Since she is family and would return soon, I decided to make an exception for her and end her all of them. Yes, I regretted it. Jean only gave it back to me this morning! I got it back, I checked if everything was in order. No, I was not! I noticed there were N-1 pens in my set. Since I was in a hurry to go to college, I ask you, Billie, to help me find which pen is missing. Consider that all pens are identified by integers in the interval [1, N]. I hope the pen that is missing is only lost! I can not stand the idea of Jean stealing from me!


The input is composed of several test cases. The first line has an integer N, where 2 ≤ N ≤ 105, indicating the number of pens in my set. The next lines are composed of integers N-1, indicating which pens were returned. For each terminating Ni of this sequence, consider that they are in the range of 1 ≤ Ni N.


The output is composed of a single line indicating which pen was not in the set.

Input SampleOutput Sample

14 17 16

48 15 43

1 33 49

2 8 41

21 6 30

35 37 32

50 40 13

34 12 5

39 9 47

4 46 18

23 31 7

24 10 3

42 29 19

45 27 25

38 26 44

36 22 11



16 26 15

36 37 38

20 40 23

19 24 1

22 13 2

9 7 29

39 30 21

3 18 17

35 27 11

5 8 6

12 25 14

4 31 28

34 32 33


5 2 3

1 6 8

4 9 7