Submission #56968905
Source Code Expand
Copy
import sysrints = lambda: list(map(int, sys.stdin.readline().split()))M = 60N, K = rints()A = [e - 1 for e in rints()]dp = [[0] * N for _ in range(M + 1)]dp[0] = Afor i in range(M):for j in range(N):dp[i + 1][j] = dp[i][dp[i][j]]ans = 0p = 0while K > 0:if K & 1:ans = dp[p][ans]p += 1K >>= 1print(ans + 1)
import sys rints = lambda: list(map(int, sys.stdin.readline().split())) M = 60 N, K = rints() A = [e - 1 for e in rints()] dp = [[0] * N for _ in range(M + 1)] dp[0] = A for i in range(M): for j in range(N): dp[i + 1][j] = dp[i][dp[i][j]] ans = 0 p = 0 while K > 0: if K & 1: ans = dp[p][ans] p += 1 K >>= 1 print(ans + 1)
Submission Info
Submission Time | |
---|---|
Task | D - Teleporter |
User | gigolo |
Language | Python (PyPy 3.10-v7.3.12) |
Score | 400 |
Code Size | 377 Byte |
Status | AC |
Exec Time | 244 ms |
Memory | 208044 KB |
Judge Result
Set Name | Sample | Subtask1 | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt |
Subtask1 | sample_01.txt, sample_02.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt, sub1_22.txt, sub1_23.txt, sub1_24.txt, sub1_25.txt, sub1_26.txt, sub1_27.txt, sub1_28.txt, sub1_29.txt, sub1_30.txt, sub1_31.txt, sub1_32.txt, sub1_33.txt, sub1_34.txt, sub1_35.txt, sub1_36.txt, sub1_37.txt, sub1_38.txt, sub1_39.txt, sub1_40.txt, sub1_41.txt, sub1_42.txt, sub1_43.txt, sub1_44.txt, sub1_45.txt, sub1_46.txt, sub1_47.txt, sub1_48.txt, sub1_49.txt, sub1_50.txt, sub1_51.txt, sub1_52.txt, sub1_53.txt, sub1_54.txt, sub1_55.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 61 ms | 76428 KB |
sample_02.txt | AC | 60 ms | 76376 KB |
sub1_01.txt | AC | 81 ms | 96280 KB |
sub1_02.txt | AC | 146 ms | 165240 KB |
sub1_03.txt | AC | 77 ms | 91220 KB |
sub1_04.txt | AC | 190 ms | 207552 KB |
sub1_05.txt | AC | 190 ms | 207608 KB |
sub1_06.txt | AC | 145 ms | 166672 KB |
sub1_07.txt | AC | 138 ms | 158840 KB |
sub1_08.txt | AC | 183 ms | 207616 KB |
sub1_09.txt | AC | 162 ms | 158140 KB |
sub1_10.txt | AC | 177 ms | 191808 KB |
sub1_11.txt | AC | 114 ms | 132768 KB |
sub1_12.txt | AC | 202 ms | 207576 KB |
sub1_13.txt | AC | 212 ms | 207916 KB |
sub1_14.txt | AC | 216 ms | 207676 KB |
sub1_15.txt | AC | 148 ms | 166364 KB |
sub1_16.txt | AC | 188 ms | 208044 KB |
sub1_17.txt | AC | 149 ms | 166788 KB |
sub1_18.txt | AC | 189 ms | 207936 KB |
sub1_19.txt | AC | 88 ms | 103584 KB |
sub1_20.txt | AC | 201 ms | 207620 KB |
sub1_21.txt | AC | 149 ms | 160980 KB |
sub1_22.txt | AC | 177 ms | 175832 KB |
sub1_23.txt | AC | 120 ms | 134500 KB |
sub1_24.txt | AC | 202 ms | 182468 KB |
sub1_25.txt | AC | 198 ms | 179976 KB |
sub1_26.txt | AC | 159 ms | 158292 KB |
sub1_27.txt | AC | 145 ms | 150728 KB |
sub1_28.txt | AC | 170 ms | 167024 KB |
sub1_29.txt | AC | 93 ms | 110232 KB |
sub1_30.txt | AC | 140 ms | 146504 KB |
sub1_31.txt | AC | 70 ms | 81200 KB |
sub1_32.txt | AC | 146 ms | 164720 KB |
sub1_33.txt | AC | 98 ms | 114128 KB |
sub1_34.txt | AC | 137 ms | 151472 KB |
sub1_35.txt | AC | 70 ms | 81288 KB |
sub1_36.txt | AC | 196 ms | 201936 KB |
sub1_37.txt | AC | 200 ms | 201124 KB |
sub1_38.txt | AC | 234 ms | 203668 KB |
sub1_39.txt | AC | 205 ms | 195424 KB |
sub1_40.txt | AC | 88 ms | 103168 KB |
sub1_41.txt | AC | 243 ms | 207660 KB |
sub1_42.txt | AC | 240 ms | 207676 KB |
sub1_43.txt | AC | 232 ms | 207856 KB |
sub1_44.txt | AC | 237 ms | 207828 KB |
sub1_45.txt | AC | 240 ms | 207688 KB |
sub1_46.txt | AC | 188 ms | 207812 KB |
sub1_47.txt | AC | 224 ms | 207684 KB |
sub1_48.txt | AC | 244 ms | 207568 KB |
sub1_49.txt | AC | 228 ms | 207588 KB |
sub1_50.txt | AC | 189 ms | 207864 KB |
sub1_51.txt | AC | 180 ms | 194000 KB |
sub1_52.txt | AC | 127 ms | 147276 KB |
sub1_53.txt | AC | 94 ms | 110360 KB |
sub1_54.txt | AC | 202 ms | 207632 KB |
sub1_55.txt | AC | 202 ms | 207696 KB |