Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.013 s | 3 KBi |
#2 |
Incorrecto
|
0.01 s | 3 KBi |
#3 |
Incorrecto
|
0.01 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 20, in <module> parent = tree[child] KeyError: '0' |
0.02 s | 3 KBi |
#5 |
Incorrecto
|
0.016 s | 3 KBi |
#6 |
Incorrecto
|
0.01 s | 3 KBi |
#7 |
Incorrecto
|
0.022 s | 3 KBi |
#8 |
Incorrecto
|
0.018 s | 3 KBi |
#9 |
Incorrecto
|
0.015 s | 3 KBi |
#10 |
Correcto
|
0.01 s | 3 KBi |
#11 |
Incorrecto
|
0.023 s | 3 KBi |
#12 |
Incorrecto
|
0.305 s | 21 KBi |
#13 |
Incorrecto
|
0.299 s | 21 KBi |
#14 |
Incorrecto
|
0.26 s | 21 KBi |
#15 |
Incorrecto
|
0.286 s | 21 KBi |
#16 |
Tiempo límite excedido
|
1.599 s | 21 KBi |
#17 |
Tiempo límite excedido
|
1.599 s | 22 KBi |
#18 |
Tiempo límite excedido
|
1.6 s | 21 KBi |
#19 |
Tiempo límite excedido
|
1.577 s | 22 KBi |
#20 |
Tiempo límite excedido
|
1.569 s | 21 KBi |
N = int(input()) tree = {} for i in range(N - 1): treeData = input().split(' ') tree['0'] = None tree[treeData[1]] = treeData[0] # key=child, value=parent # print(tree) # exit() C = int(input()) for i in range(C): wasYes = False query = input().split(' ') ancestor = query[0] child = query[1] parent = tree[child] while parent is not None: if parent == ancestor: print('Yes') wasYes = True break elif parent < ancestor: break parent = tree[parent] if not wasYes: print('No')