Submission #56974345
Source Code Expand
Copy
import sysrints = lambda: list(map(int, sys.stdin.readline().split()))rdecints = lambda: [e - 1 for e in rints()]M = 60N, K = rints()X = rdecints()A = rints()dp = [[0] * N for _ in range(M)]dp[0] = Xfor i in range(M - 1):for j in range(N):dp[i + 1][j] = dp[i][dp[i][j]]ind = list(range(N))p = 0while K > 0:if K & 1:for i in range(N):ind[i] = dp[p][ind[i]]
import sys rints = lambda: list(map(int, sys.stdin.readline().split())) rdecints = lambda: [e - 1 for e in rints()] M = 60 N, K = rints() X = rdecints() A = rints() dp = [[0] * N for _ in range(M)] dp[0] = X for i in range(M - 1): for j in range(N): dp[i + 1][j] = dp[i][dp[i][j]] ind = list(range(N)) p = 0 while K > 0: if K & 1: for i in range(N): ind[i] = dp[p][ind[i]] p += 1 K >>= 1 print(" ".join([str(A[ind[i]]) for i in range(N)]))
Submission Info
Submission Time | |
---|---|
Task | E - Permute K times |
User | gigolo |
Language | Python (PyPy 3.10-v7.3.12) |
Score | 450 |
Code Size | 511 Byte |
Status | AC |
Exec Time | 353 ms |
Memory | 209832 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 450 / 450 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt, test_47.txt, test_48.txt, test_49.txt, test_50.txt, test_51.txt, test_52.txt, test_53.txt, test_54.txt, test_55.txt, test_56.txt, test_57.txt, test_58.txt, test_59.txt, test_60.txt, test_61.txt, test_62.txt, test_63.txt, test_64.txt, test_65.txt, test_66.txt, test_67.txt, test_68.txt, test_69.txt, test_70.txt, test_71.txt, test_72.txt, test_73.txt, test_74.txt, test_75.txt, test_76.txt, test_77.txt, test_78.txt, test_79.txt, test_80.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 58 ms | 76080 KB |
sample_02.txt | AC | 59 ms | 76076 KB |
sample_03.txt | AC | 59 ms | 75824 KB |
test_01.txt | AC | 57 ms | 75856 KB |
test_02.txt | AC | 58 ms | 75836 KB |
test_03.txt | AC | 127 ms | 121996 KB |
test_04.txt | AC | 297 ms | 209392 KB |
test_05.txt | AC | 274 ms | 196300 KB |
test_06.txt | AC | 209 ms | 179256 KB |
test_07.txt | AC | 68 ms | 80896 KB |
test_08.txt | AC | 115 ms | 121844 KB |
test_09.txt | AC | 210 ms | 184888 KB |
test_10.txt | AC | 306 ms | 209464 KB |
test_11.txt | AC | 307 ms | 209728 KB |
test_12.txt | AC | 88 ms | 100784 KB |
test_13.txt | AC | 198 ms | 166156 KB |
test_14.txt | AC | 341 ms | 209464 KB |
test_15.txt | AC | 87 ms | 93524 KB |
test_16.txt | AC | 129 ms | 138252 KB |
test_17.txt | AC | 103 ms | 111664 KB |
test_18.txt | AC | 107 ms | 115340 KB |
test_19.txt | AC | 186 ms | 167656 KB |
test_20.txt | AC | 310 ms | 209780 KB |
test_21.txt | AC | 294 ms | 209832 KB |
test_22.txt | AC | 67 ms | 80948 KB |
test_23.txt | AC | 221 ms | 209380 KB |
test_24.txt | AC | 222 ms | 209684 KB |
test_25.txt | AC | 220 ms | 209736 KB |
test_26.txt | AC | 224 ms | 209804 KB |
test_27.txt | AC | 227 ms | 209820 KB |
test_28.txt | AC | 221 ms | 209692 KB |
test_29.txt | AC | 79 ms | 93176 KB |
test_30.txt | AC | 253 ms | 209772 KB |
test_31.txt | AC | 300 ms | 209696 KB |
test_32.txt | AC | 72 ms | 81260 KB |
test_33.txt | AC | 321 ms | 197752 KB |
test_34.txt | AC | 344 ms | 209652 KB |
test_35.txt | AC | 164 ms | 159904 KB |
test_36.txt | AC | 66 ms | 80696 KB |
test_37.txt | AC | 160 ms | 157056 KB |
test_38.txt | AC | 94 ms | 106564 KB |
test_39.txt | AC | 258 ms | 209648 KB |
test_40.txt | AC | 257 ms | 209772 KB |
test_41.txt | AC | 233 ms | 209492 KB |
test_42.txt | AC | 89 ms | 103296 KB |
test_43.txt | AC | 91 ms | 101344 KB |
test_44.txt | AC | 224 ms | 209460 KB |
test_45.txt | AC | 106 ms | 120008 KB |
test_46.txt | AC | 93 ms | 105208 KB |
test_47.txt | AC | 218 ms | 194312 KB |
test_48.txt | AC | 109 ms | 122480 KB |
test_49.txt | AC | 177 ms | 187108 KB |
test_50.txt | AC | 231 ms | 209640 KB |
test_51.txt | AC | 228 ms | 209756 KB |
test_52.txt | AC | 139 ms | 141580 KB |
test_53.txt | AC | 103 ms | 114436 KB |
test_54.txt | AC | 249 ms | 209400 KB |
test_55.txt | AC | 111 ms | 124932 KB |
test_56.txt | AC | 157 ms | 166372 KB |
test_57.txt | AC | 140 ms | 153724 KB |
test_58.txt | AC | 90 ms | 104116 KB |
test_59.txt | AC | 226 ms | 206140 KB |
test_60.txt | AC | 239 ms | 209556 KB |
test_61.txt | AC | 226 ms | 209508 KB |
test_62.txt | AC | 224 ms | 209524 KB |
test_63.txt | AC | 228 ms | 209432 KB |
test_64.txt | AC | 219 ms | 209324 KB |
test_65.txt | AC | 165 ms | 154024 KB |
test_66.txt | AC | 207 ms | 180760 KB |
test_67.txt | AC | 131 ms | 140404 KB |
test_68.txt | AC | 94 ms | 106188 KB |
test_69.txt | AC | 214 ms | 185996 KB |
test_70.txt | AC | 316 ms | 209400 KB |
test_71.txt | AC | 327 ms | 209404 KB |
test_72.txt | AC | 254 ms | 182448 KB |
test_73.txt | AC | 112 ms | 114508 KB |
test_74.txt | AC | 353 ms | 209188 KB |
test_75.txt | AC | 240 ms | 209444 KB |
test_76.txt | AC | 220 ms | 209464 KB |
test_77.txt | AC | 231 ms | 209724 KB |
test_78.txt | AC | 238 ms | 209792 KB |
test_79.txt | AC | 237 ms | 209552 KB |
test_80.txt | AC | 257 ms | 209032 KB |