Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.01 s | 3 KBi |
#2 |
Incorrecto
|
0.01 s | 3 KBi |
#3 |
Incorrecto
|
0.029 s | 6 KBi |
#4 |
Correcto
|
0.022 s | 3 KBi |
#5 |
Incorrecto
|
0.022 s | 3 KBi |
#6 |
Incorrecto
|
0.022 s | 3 KBi |
#7 |
Incorrecto
|
0.022 s | 3 KBi |
#8 |
Incorrecto
|
0.023 s | 3 KBi |
#9 |
Incorrecto
|
0.013 s | 3 KBi |
#10 |
Incorrecto
|
0.017 s | 3 KBi |
#11 |
Incorrecto
|
0.01 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 28, in <module> print(memo) OSError: [Errno 27] File too large |
0.154 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 28, in <module> print(memo) OSError: [Errno 27] File too large |
0.159 s | 25 KBi |
#14 |
Error en tiempo de ejecución (NZEC)
Exited with error status 1 Traceback (most recent call last): File "script.py", line 28, in <module> print(memo) OSError: [Errno 27] File too large |
0.156 s | 25 KBi |
#15 |
Error en tiempo de ejecución (NZEC)
Exited with error status 120 Traceback (most recent call last): File "script.py", line 28, in <module> print(memo) OSError: [Errno 27] File too large Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> OSError: [Errno 27] File too large |
0.442 s | 26 KBi |
#16 |
Tiempo límite excedido
|
1.514 s | 21 KBi |
#17 |
Tiempo límite excedido
|
1.559 s | 21 KBi |
#18 |
Tiempo límite excedido
|
1.555 s | 21 KBi |
#19 |
Tiempo límite excedido
|
1.601 s | 21 KBi |
#20 |
Tiempo límite excedido
|
1.57 s | 21 KBi |
N = int(input()) tree = {} memo = {} for i in range(N - 1): treeData = input().split(' ') tree[treeData[1]] = treeData[0] C = int(input()) for i in range(C): wasYes = False query = input().split(' ') ancestor = query[0] child = query[1] memo[child] = {} if ancestor == '0' or ancestor == child: print('Yes') continue try: parent = tree[child] except: parent = None print(memo) while parent is not None: # if parent == ancestor or (parent in memo and ancestor in memo[parent]): if parent == ancestor: print('Yes') wasYes = True break # memo[child][parent] = True try: parent = tree[parent] except: parent = None if not wasYes: print('No')