Submission #7613218


Source Code Expand

from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


import queue
from collections import deque



def main():
    tate_num, yoko_num, d = map(int, input(). split())
    data = list(map(int, input().split()))

    goal_data_kari = [i for i in range(tate_num + 1)]
    for i in range(yoko_num):
        ind = data[i]
        goal_data_kari[ind], goal_data_kari[ind + 1] = goal_data_kari[ind + 1], goal_data_kari[ind]

    goal_data = [0 for i in range(tate_num + 1)]
    for i in range(1, tate_num + 1):
        goal_data[goal_data_kari[i]] = i

    ans_list = [0 for i in range(tate_num + 1)]

    for i in range(1, tate_num + 1):
        if ans_list[i]:
            continue
        count = 0
        start = i
        now_tate = i
        while 1:
            now_tate = goal_data[now_tate]
            count += 1
            if now_tate == start:
                break
        amari = d % count
        for j in range(amari):
            now_tate = goal_data[now_tate]

        while ans_list[start] == 0:
            ans_list[start] = now_tate
            start = goal_data[start]
            now_tate = goal_data[now_tate]

    for i in range(1, tate_num + 1):
        print(ans_list[i])







if __name__ == '__main__':
    main()

Submission Info

Submission Time
Task D - 阿弥陀
User traymihael
Language PyPy3 (2.4.0)
Score 100
Code Size 1446 Byte
Status AC
Exec Time 389 ms
Memory 81280 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 351 ms 80896 KB
01_random01.txt AC 186 ms 38508 KB
01_random02.txt AC 185 ms 38508 KB
01_random03.txt AC 180 ms 38508 KB
01_random04.txt AC 243 ms 44140 KB
01_random05.txt AC 332 ms 53796 KB
01_random06.txt AC 361 ms 67308 KB
01_random07.txt AC 376 ms 81280 KB
02_i.txt AC 212 ms 39788 KB
02_p.txt AC 206 ms 39276 KB
02_random01.txt AC 186 ms 38508 KB
02_random02.txt AC 186 ms 38508 KB
02_random03.txt AC 203 ms 39148 KB
02_random04.txt AC 203 ms 39276 KB
02_random05.txt AC 210 ms 41068 KB
02_random06.txt AC 233 ms 51820 KB
02_random07.txt AC 264 ms 64772 KB
02_random08.txt AC 259 ms 64772 KB
02_rp01.txt AC 203 ms 39276 KB
02_rp02.txt AC 204 ms 39276 KB
02_rp03.txt AC 204 ms 39276 KB
02_rp04.txt AC 209 ms 39276 KB
02_rp05.txt AC 199 ms 39276 KB
03_i.txt AC 186 ms 38508 KB
03_random01.txt AC 192 ms 40044 KB
03_random02.txt AC 238 ms 61292 KB
03_random03.txt AC 227 ms 56812 KB
03_random04.txt AC 222 ms 56684 KB
03_random05.txt AC 196 ms 41452 KB
03_random06.txt AC 196 ms 41068 KB
03_random07.txt AC 195 ms 43116 KB
03_random08.txt AC 192 ms 39148 KB
03_random09.txt AC 211 ms 45592 KB
03_random10.txt AC 218 ms 50796 KB
03_random11.txt AC 232 ms 59244 KB
03_random12.txt AC 239 ms 61164 KB
03_random13.txt AC 231 ms 56300 KB
03_random14.txt AC 218 ms 52460 KB
03_random15.txt AC 205 ms 43500 KB
04_i.txt AC 367 ms 80640 KB
04_p1.txt AC 313 ms 58940 KB
04_p2.txt AC 301 ms 53456 KB
04_random01.txt AC 326 ms 59516 KB
04_random02.txt AC 321 ms 52160 KB
04_random03.txt AC 292 ms 53740 KB
04_random04.txt AC 315 ms 70636 KB
04_random05.txt AC 316 ms 60496 KB
04_random06.txt AC 327 ms 54704 KB
04_random07.txt AC 339 ms 74696 KB
04_random08.txt AC 337 ms 69100 KB
04_random09.txt AC 339 ms 73324 KB
04_random10.txt AC 325 ms 53872 KB
04_random11.txt AC 374 ms 80768 KB
04_random12.txt AC 389 ms 81280 KB
04_random13.txt AC 372 ms 80896 KB
04_rp01.txt AC 312 ms 58928 KB
04_rp02.txt AC 311 ms 58928 KB
04_rp03.txt AC 306 ms 58928 KB
04_rp04.txt AC 307 ms 58932 KB
04_rp05.txt AC 314 ms 58928 KB
04_rp06.txt AC 318 ms 58928 KB
04_rp07.txt AC 316 ms 58928 KB
04_rp08.txt AC 316 ms 58932 KB
04_rp09.txt AC 313 ms 58932 KB
04_rp10.txt AC 313 ms 58928 KB
sample_1.txt AC 190 ms 38508 KB
sample_2.txt AC 184 ms 38508 KB
sample_3.txt AC 187 ms 38508 KB