Блог пользователя dashrath1526

Автор dashrath1526, история, 4 года назад, По-английски

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.'

  • Проголосовать: нравится
  • -3
  • Проголосовать: не нравится

»
4 года назад, # |
Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

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

»
4 года назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

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 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      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