Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.01 s | 3 KBi |
#2 |
Correcto
|
0.011 s | 3 KBi |
#3 |
Correcto
|
0.011 s | 3 KBi |
#4 |
Correcto
|
0.036 s | 3 KBi |
#5 |
Correcto
|
0.011 s | 3 KBi |
#6 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/python-3.8.1/bin/python3 script.py |
0.332 s | 125 KBi |
#7 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/python-3.8.1/bin/python3 script.py |
0.329 s | 125 KBi |
#8 |
Correcto
|
0.012 s | 3 KBi |
#9 |
Correcto
|
0.011 s | 3 KBi |
#10 |
Correcto
|
0.013 s | 3 KBi |
#11 |
Correcto
|
0.011 s | 3 KBi |
#12 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/python-3.8.1/bin/python3 script.py |
0.592 s | 125 KBi |
#13 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/python-3.8.1/bin/python3 script.py |
0.388 s | 125 KBi |
#14 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/python-3.8.1/bin/python3 script.py |
0.403 s | 125 KBi |
#15 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/python-3.8.1/bin/python3 script.py |
0.379 s | 125 KBi |
#16 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/python-3.8.1/bin/python3 script.py |
0.384 s | 125 KBi |
#17 |
Correcto
|
0.015 s | 3 KBi |
#18 |
Correcto
|
0.013 s | 3 KBi |
#19 |
Correcto
|
0.014 s | 3 KBi |
#20 |
Correcto
|
0.013 s | 3 KBi |
#21 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/python-3.8.1/bin/python3 script.py |
0.337 s | 125 KBi |
#22 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/python-3.8.1/bin/python3 script.py |
0.321 s | 125 KBi |
#23 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/python-3.8.1/bin/python3 script.py |
0.687 s | 125 KBi |
#24 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/python-3.8.1/bin/python3 script.py |
0.686 s | 125 KBi |
#25 |
Error en tiempo de ejecución (NZEC)
Exited with error status 137 run: line 1: 3 Killed /usr/local/python-3.8.1/bin/python3 script.py |
0.458 s | 125 KBi |
def init_matrix(n, p): m = [[0 for _ in range(n)] for _ in range(n)] for i, v in enumerate(p): m[v][i] = 1 return m def prod(X, Y): return [[sum(a*b for a,b in zip(X_row,Y_col)) for Y_col in zip(*Y)] for X_row in X] # could be a single # edge case but I find # this very elegant def diag(mat): m = [[0 for _ in range(len(mat[0]))] for _ in range(len(mat))] for i in range(len(mat)): m[i][i] = 1 return m def _pow(m, k): if k == 0: return diag(m) elif k % 2 == 0: half = _pow(m, k >> 1) return prod(half, half) else: half = _pow(m, k >> 1) return prod(half, prod(half, m)) N, K = map(int, input().split(" ")) P = list(map(int, input().split(" "))) V = [[n] for n in range(1, N + 1)] M = init_matrix(N, P) print(" ".join(str(l.pop()) for l in prod(_pow(M, K), V)))