█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 6367

Problema 0x1c - Decir si un nodo es ancestro de otro en un árbol

  • Autor: Jorgito
  • Fecha: 2022-06-27 17:31:51 UTC (Hace más de 2 años)
Caso # Resultado Tiempo Memoria
#1
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 22, in <module>
    parent = three[child] # we return the value, that means the parent
KeyError: '0'
0.012 s 3 KBi
#2
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 22, in <module>
    parent = three[child] # we return the value, that means the parent
KeyError: '0'
0.011 s 3 KBi
#3
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 22, in <module>
    parent = three[child] # we return the value, that means the parent
KeyError: '0'
0.023 s 3 KBi
#4
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 22, in <module>
    parent = three[child] # we return the value, that means the parent
KeyError: '0'
0.015 s 3 KBi
#5
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 22, in <module>
    parent = three[child] # we return the value, that means the parent
KeyError: '0'
0.027 s 3 KBi
#6
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 22, in <module>
    parent = three[child] # we return the value, that means the parent
KeyError: '0'
0.026 s 3 KBi
#7
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 22, in <module>
    parent = three[child] # we return the value, that means the parent
KeyError: '0'
0.012 s 3 KBi
#8
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 22, in <module>
    parent = three[child] # we return the value, that means the parent
KeyError: '0'
0.024 s 3 KBi
#9
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 22, in <module>
    parent = three[child] # we return the value, that means the parent
KeyError: '0'
0.028 s 3 KBi
#10
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 22, in <module>
    parent = three[child] # we return the value, that means the parent
KeyError: '0'
0.011 s 3 KBi
#11
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 22, in <module>
    parent = three[child] # we return the value, that means the parent
KeyError: '0'
0.033 s 3 KBi
#12
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 22, in <module>
    parent = three[child] # we return the value, that means the parent
KeyError: '0'
0.136 s 25 KBi
#13
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 22, in <module>
    parent = three[child] # we return the value, that means the parent
KeyError: '0'
0.526 s 25 KBi
#14
Incorrecto
0.189 s 25 KBi
#15
Error en tiempo de ejecución (NZEC)
Exited with error status 1
Traceback (most recent call last):
  File "script.py", line 22, in <module>
    parent = three[child] # we return the value, that means the parent
KeyError: '0'
0.57 s 25 KBi
#16
Incorrecto
0.177 s 25 KBi
#17
Incorrecto
0.504 s 25 KBi
#18
Incorrecto
0.172 s 25 KBi
#19
Incorrecto
0.231 s 25 KBi
#20
Incorrecto
0.171 s 25 KBi
Puntos totales: 0 / 100

Código

N = int(input())

three = {}

for i in range(N-1):
    elements = input().split()
    parent = elements[0]
    child = elements[1]
    three[child] = parent

print(three)

iterar = int(input())
for i in range(iterar):
    know = input().split() # {"2":1}  [2, 1]
    father = know[0]
    child = know[1]
    
    if father == child:
        print('YES')
    
    parent = three[child] # we return the value, that means the parent
    while parent is not None:
        if parent == father:
            print("Yes")
        break