dashrath1526's blog

By dashrath1526, history, 4 years ago, In English

Problem link

n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
xy = set(x)
xy.update(y)

flag = False
while n > 0:
    if n in xy:
        n -= 1
        continue
    else:
        flag = True
        break

if flag:
    print('Oh, my keyboard!')
else:
    print('I become the guy.')

As per my understanding of the problem desc, I am not missing anything here. I am new here so correct me if I am wrong.

Test case description. Input 3

1 2

2 2 3

Participant's output I become the guy.

Jury's answer Oh, my keyboard!

Checker comment wrong answer 1st lines differ — expected: 'Oh, my keyboard!', found: 'I become the guy.'

  • Vote: I like it
  • -3
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

I think your mistake is that you are considering the number of indices that each player can pass as an index.

»
4 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

In the test case you are failing there are 3 levels that need to be passed (1,2,3) and the levels that can be passed are only 2 and 3 therefore the output should be "Oh, my keyboard!". I would suggest building an array from 1 to n (for 1 indexing) which would have only ones in it. And for every number you scan set the element with that index to 0.Also, looking at your solution I can see that you also take the first number in consideration, but you shouldn’t because it is the number of levels the player can pass but not a level the player can pass itself . Then make a linear scan and check if there is any number equal to one in the array. If there is at least one one then the answer is "Oh, my keyboard!", otherwise it's "I become the guy.".

Here's my implimentation in cpp:

And Here's my implimentation in Python

  • »
    »
    4 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Your solution is correct, but reasoning on below condition. This is what mentioned in problem explanation.

    levels need to be passed: 1 2 3 x can pass: 1 2 y can pass: 2 2 3 x and y together can pass : 1 2 3

    isn't it right?

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      X and Y can pass together only 2 and 3. If you read the input details firstly you scan the number of levels x can pass and then the levels x can pass and the same goes for y