結果

問題 No.1013 〇マス進む
ユーザー 👑 hos.lyrichos.lyric
提出日時 2020-03-27 13:24:04
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 1,903 bytes
コンパイル時間 2,068 ms
コンパイル使用メモリ 107,108 KB
実行使用メモリ 30,552 KB
最終ジャッジ日時 2023-09-04 06:27:49
合計ジャッジ時間 7,891 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 4 ms
4,844 KB
testcase_14 AC 33 ms
8,748 KB
testcase_15 AC 54 ms
11,076 KB
testcase_16 AC 48 ms
11,352 KB
testcase_17 AC 27 ms
6,856 KB
testcase_18 AC 38 ms
9,244 KB
testcase_19 AC 19 ms
5,268 KB
testcase_20 AC 61 ms
11,260 KB
testcase_21 AC 26 ms
6,832 KB
testcase_22 AC 37 ms
9,012 KB
testcase_23 AC 12 ms
4,484 KB
testcase_24 AC 64 ms
13,124 KB
testcase_25 AC 63 ms
13,312 KB
testcase_26 AC 14 ms
5,732 KB
testcase_27 AC 23 ms
6,324 KB
testcase_28 AC 12 ms
4,380 KB
testcase_29 AC 58 ms
11,236 KB
testcase_30 AC 23 ms
6,344 KB
testcase_31 AC 42 ms
9,912 KB
testcase_32 AC 30 ms
8,948 KB
testcase_33 AC 51 ms
14,792 KB
testcase_34 AC 83 ms
21,620 KB
testcase_35 AC 88 ms
20,188 KB
testcase_36 AC 7 ms
4,904 KB
testcase_37 AC 7 ms
4,376 KB
testcase_38 AC 90 ms
22,724 KB
testcase_39 AC 34 ms
10,036 KB
testcase_40 AC 101 ms
22,596 KB
testcase_41 AC 24 ms
7,544 KB
testcase_42 AC 53 ms
13,548 KB
testcase_43 AC 34 ms
9,300 KB
testcase_44 AC 57 ms
14,836 KB
testcase_45 AC 50 ms
13,076 KB
testcase_46 AC 26 ms
7,840 KB
testcase_47 AC 47 ms
12,972 KB
testcase_48 AC 56 ms
15,928 KB
testcase_49 AC 97 ms
20,748 KB
testcase_50 AC 75 ms
20,488 KB
testcase_51 AC 66 ms
16,320 KB
testcase_52 AC 16 ms
6,472 KB
testcase_53 AC 21 ms
7,104 KB
testcase_54 AC 79 ms
21,440 KB
testcase_55 AC 29 ms
8,948 KB
testcase_56 AC 116 ms
25,540 KB
testcase_57 AC 83 ms
19,404 KB
testcase_58 AC 140 ms
29,036 KB
testcase_59 AC 132 ms
29,564 KB
testcase_60 AC 123 ms
30,552 KB
testcase_61 AC 58 ms
11,592 KB
testcase_62 AC 43 ms
6,180 KB
testcase_63 AC 2 ms
4,376 KB
testcase_64 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const N = readInt();
      const K = readLong();
      auto P = new int[N];
      foreach (i; 0 .. N) {
        P[i] = readInt();
      }
      
      const E = bsr(K) + 1;
      auto f = new long[][](E, N);
      foreach (i; 0 .. N) {
        f[0][i] = P[i];
      }
      foreach (e; 0 .. E - 1) {
        foreach (i; 0 .. N) {
          f[e + 1][i] = f[e][i] + f[e][cast(int)((i + f[e][i]) % N)];
        }
      }
      
      foreach (i; 0 .. N) {
        long ans = i;
        foreach_reverse (e; 0 .. E) {
          if (K & 1L << e) {
            ans += f[e][cast(int)(ans % N)];
          }
        }
        writeln(ans + 1);
      }
    }
  } catch (EOFException e) {
  }
}
0