Submission #1191043


Source Code Expand

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int D = sc.nextInt();
    int[] id = new int[N + 1];
    for(int i = 0; i < N + 1; i++) {
      id[i] = i;
    }
    for(int i = 0; i < M; i++) {
      int a = sc.nextInt();
      int temp = id[a];
      id[a] = id[a + 1];
      id[a + 1] = temp;
    }
    int[] goal = new int[N + 1];
    for(int i = 1; i < N + 1; i++) {
      goal[id[i]] = i;
    }
    // powGoal[i][j]はiから出発して、2^j回阿弥陀を繰り返した後のgoalを表す
    int[][] powGoal = new int[N + 1][31];
    for(int i = 1; i < N + 1; i++) {
      powGoal[i][0] = goal[i];
    }
    for(int j = 1; j < 31; j++) {
      for(int i = 1; i < N + 1; i++) {
        powGoal[i][j] = powGoal[powGoal[i][j - 1]][j - 1];
      } 
    }
    for(int i = 1; i < N + 1; i++) {
      int g = i;
      for(int j = 0; j < 30; j++) {
        if((D & (1 << j)) != 0) {
          g = powGoal[g][j];
        }
      }
      System.out.println(g);
    }
  }
}

Submission Info

Submission Time
Task D - 阿弥陀
User takeya
Language Java8 (OpenJDK 1.8.0)
Score 100
Code Size 1147 Byte
Status AC
Exec Time 1188 ms
Memory 87640 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 1188 ms 87640 KB
01_random01.txt AC 92 ms 20564 KB
01_random02.txt AC 94 ms 21716 KB
01_random03.txt AC 96 ms 21844 KB
01_random04.txt AC 248 ms 29692 KB
01_random05.txt AC 981 ms 68364 KB
01_random06.txt AC 1123 ms 83344 KB
01_random07.txt AC 1076 ms 81620 KB
02_i.txt AC 182 ms 28384 KB
02_p.txt AC 172 ms 23476 KB
02_random01.txt AC 91 ms 19924 KB
02_random02.txt AC 91 ms 19924 KB
02_random03.txt AC 187 ms 25472 KB
02_random04.txt AC 131 ms 20308 KB
02_random05.txt AC 280 ms 40076 KB
02_random06.txt AC 423 ms 46352 KB
02_random07.txt AC 524 ms 60348 KB
02_random08.txt AC 511 ms 61232 KB
02_rp01.txt AC 165 ms 28420 KB
02_rp02.txt AC 147 ms 26200 KB
02_rp03.txt AC 172 ms 25836 KB
02_rp04.txt AC 160 ms 24524 KB
02_rp05.txt AC 163 ms 24560 KB
03_i.txt AC 97 ms 21716 KB
03_random01.txt AC 217 ms 37260 KB
03_random02.txt AC 509 ms 60356 KB
03_random03.txt AC 441 ms 60492 KB
03_random04.txt AC 450 ms 59728 KB
03_random05.txt AC 267 ms 38416 KB
03_random06.txt AC 241 ms 38388 KB
03_random07.txt AC 284 ms 40532 KB
03_random08.txt AC 141 ms 25816 KB
03_random09.txt AC 294 ms 43128 KB
03_random10.txt AC 350 ms 48180 KB
03_random11.txt AC 447 ms 59216 KB
03_random12.txt AC 500 ms 60232 KB
03_random13.txt AC 452 ms 60844 KB
03_random14.txt AC 396 ms 55480 KB
03_random15.txt AC 282 ms 43772 KB
04_i.txt AC 1138 ms 82072 KB
04_p1.txt AC 996 ms 73360 KB
04_p2.txt AC 861 ms 47448 KB
04_random01.txt AC 956 ms 74572 KB
04_random02.txt AC 652 ms 50684 KB
04_random03.txt AC 575 ms 47248 KB
04_random04.txt AC 606 ms 61528 KB
04_random05.txt AC 602 ms 61520 KB
04_random06.txt AC 761 ms 47104 KB
04_random07.txt AC 734 ms 64608 KB
04_random08.txt AC 795 ms 72292 KB
04_random09.txt AC 683 ms 61548 KB
04_random10.txt AC 754 ms 55896 KB
04_random11.txt AC 1061 ms 82888 KB
04_random12.txt AC 1163 ms 80164 KB
04_random13.txt AC 1056 ms 84948 KB
04_rp01.txt AC 997 ms 72848 KB
04_rp02.txt AC 1159 ms 81904 KB
04_rp03.txt AC 1006 ms 72568 KB
04_rp04.txt AC 1015 ms 73312 KB
04_rp05.txt AC 979 ms 71988 KB
04_rp06.txt AC 1095 ms 76560 KB
04_rp07.txt AC 1068 ms 74960 KB
04_rp08.txt AC 1093 ms 83356 KB
04_rp09.txt AC 949 ms 71784 KB
04_rp10.txt AC 1029 ms 73088 KB
sample_1.txt AC 95 ms 20692 KB
sample_2.txt AC 91 ms 19796 KB
sample_3.txt AC 94 ms 19796 KB