Submission #1988362


Source Code Expand

# O(N)

N, M, D = map(int, input().split())
A = map(lambda s: int(s) - 1, input().split())

fr = list(range(N))
for a in A:
  fr[a], fr[a + 1] = fr[a + 1], fr[a]

to = [-1] * N
for i in range(N):
  to[fr[i]] = i

res = [-1] * N

for i in range(N):
  if to[i] >= 0:  
    cyc = []
    while to[i] >= 0:
      cyc.append(i)
      t = i
      i, to[t] = to[t], -1

    cyc_len = len(cyc)
    for j in range(cyc_len):
      res[cyc[j]] = cyc[(j + D) % cyc_len]

for p in res:
  print(p + 1)

Submission Info

Submission Time
Task D - 阿弥陀
User japlj
Language Python (3.4.3)
Score 100
Code Size 516 Byte
Status AC
Exec Time 458 ms
Memory 20924 KB

Judge Result

Set Name Subtask1 Subtask2 Subtask3 Subtask4
Score / Max Score 10 / 10 20 / 20 20 / 20 50 / 50
Status
AC × 9
AC × 18
AC × 18
AC × 29
Set Name Test Cases
Subtask1 sample_1.txt, 01_i.txt, 01_random01.txt, 01_random02.txt, 01_random03.txt, 01_random04.txt, 01_random05.txt, 01_random06.txt, 01_random07.txt
Subtask2 sample_1.txt, sample_2.txt, sample_3.txt, 02_i.txt, 02_p.txt, 02_random01.txt, 02_random02.txt, 02_random03.txt, 02_random04.txt, 02_random05.txt, 02_random06.txt, 02_random07.txt, 02_random08.txt, 02_rp01.txt, 02_rp02.txt, 02_rp03.txt, 02_rp04.txt, 02_rp05.txt
Subtask3 sample_1.txt, sample_2.txt, 03_i.txt, 03_random01.txt, 03_random02.txt, 03_random03.txt, 03_random04.txt, 03_random05.txt, 03_random06.txt, 03_random07.txt, 03_random08.txt, 03_random09.txt, 03_random10.txt, 03_random11.txt, 03_random12.txt, 03_random13.txt, 03_random14.txt, 03_random15.txt
Subtask4 sample_1.txt, sample_2.txt, sample_3.txt, 04_i.txt, 04_p1.txt, 04_p2.txt, 04_random01.txt, 04_random02.txt, 04_random03.txt, 04_random04.txt, 04_random05.txt, 04_random06.txt, 04_random07.txt, 04_random08.txt, 04_random09.txt, 04_random10.txt, 04_random11.txt, 04_random12.txt, 04_random13.txt, 04_rp01.txt, 04_rp02.txt, 04_rp03.txt, 04_rp04.txt, 04_rp05.txt, 04_rp06.txt, 04_rp07.txt, 04_rp08.txt, 04_rp09.txt, 04_rp10.txt
Case Name Status Exec Time Memory
01_i.txt AC 354 ms 20924 KB
01_random01.txt AC 17 ms 3064 KB
01_random02.txt AC 17 ms 3064 KB
01_random03.txt AC 17 ms 3064 KB
01_random04.txt AC 28 ms 4168 KB
01_random05.txt AC 251 ms 12628 KB
01_random06.txt AC 309 ms 17556 KB
01_random07.txt AC 326 ms 19568 KB
02_i.txt AC 21 ms 3316 KB
02_p.txt AC 19 ms 3188 KB
02_random01.txt AC 17 ms 3064 KB
02_random02.txt AC 17 ms 3064 KB
02_random03.txt AC 21 ms 3316 KB
02_random04.txt AC 19 ms 3188 KB
02_random05.txt AC 31 ms 4468 KB
02_random06.txt AC 82 ms 10228 KB
02_random07.txt AC 141 ms 18240 KB
02_random08.txt AC 137 ms 17140 KB
02_rp01.txt AC 19 ms 3316 KB
02_rp02.txt AC 19 ms 3316 KB
02_rp03.txt AC 19 ms 3316 KB
02_rp04.txt AC 19 ms 3316 KB
02_rp05.txt AC 19 ms 3316 KB
03_i.txt AC 17 ms 3064 KB
03_random01.txt AC 26 ms 3188 KB
03_random02.txt AC 112 ms 5240 KB
03_random03.txt AC 98 ms 5052 KB
03_random04.txt AC 113 ms 4996 KB
03_random05.txt AC 33 ms 3640 KB
03_random06.txt AC 32 ms 3444 KB
03_random07.txt AC 40 ms 3572 KB
03_random08.txt AC 19 ms 3064 KB
03_random09.txt AC 48 ms 3700 KB
03_random10.txt AC 70 ms 4440 KB
03_random11.txt AC 117 ms 5132 KB
03_random12.txt AC 118 ms 5256 KB
03_random13.txt AC 91 ms 4820 KB
03_random14.txt AC 78 ms 4512 KB
03_random15.txt AC 40 ms 3572 KB
04_i.txt AC 374 ms 19572 KB
04_p1.txt AC 228 ms 14004 KB
04_p2.txt AC 192 ms 12076 KB
04_random01.txt AC 186 ms 11940 KB
04_random02.txt AC 128 ms 7904 KB
04_random03.txt AC 102 ms 10000 KB
04_random04.txt AC 149 ms 15836 KB
04_random05.txt AC 137 ms 14172 KB
04_random06.txt AC 187 ms 10796 KB
04_random07.txt AC 222 ms 16692 KB
04_random08.txt AC 175 ms 16612 KB
04_random09.txt AC 174 ms 18228 KB
04_random10.txt AC 173 ms 9388 KB
04_random11.txt AC 458 ms 20924 KB
04_random12.txt AC 326 ms 19568 KB
04_random13.txt AC 338 ms 20924 KB
04_rp01.txt AC 226 ms 13240 KB
04_rp02.txt AC 239 ms 13240 KB
04_rp03.txt AC 238 ms 13812 KB
04_rp04.txt AC 232 ms 13240 KB
04_rp05.txt AC 236 ms 13812 KB
04_rp06.txt AC 249 ms 13812 KB
04_rp07.txt AC 244 ms 13240 KB
04_rp08.txt AC 228 ms 13240 KB
04_rp09.txt AC 225 ms 13812 KB
04_rp10.txt AC 228 ms 13812 KB
sample_1.txt AC 17 ms 3064 KB
sample_2.txt AC 17 ms 3064 KB
sample_3.txt AC 17 ms 3064 KB