結果

問題 No.1013 〇マス進む
ユーザー polylogKpolylogK
提出日時 2020-03-20 22:01:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 1,043 bytes
コンパイル時間 2,586 ms
コンパイル使用メモリ 173,136 KB
実行使用メモリ 42,044 KB
最終ジャッジ日時 2023-08-21 16:36:18
合計ジャッジ時間 8,481 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,388 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,384 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 32 ms
21,856 KB
testcase_15 AC 54 ms
33,368 KB
testcase_16 AC 49 ms
30,864 KB
testcase_17 AC 29 ms
19,476 KB
testcase_18 AC 36 ms
22,928 KB
testcase_19 AC 21 ms
14,888 KB
testcase_20 AC 66 ms
39,888 KB
testcase_21 AC 26 ms
18,020 KB
testcase_22 AC 36 ms
23,888 KB
testcase_23 AC 12 ms
9,784 KB
testcase_24 AC 66 ms
41,252 KB
testcase_25 AC 65 ms
40,344 KB
testcase_26 AC 12 ms
9,940 KB
testcase_27 AC 25 ms
17,224 KB
testcase_28 AC 12 ms
9,904 KB
testcase_29 AC 64 ms
39,428 KB
testcase_30 AC 22 ms
15,772 KB
testcase_31 AC 41 ms
27,092 KB
testcase_32 AC 30 ms
21,096 KB
testcase_33 AC 33 ms
20,992 KB
testcase_34 AC 55 ms
31,376 KB
testcase_35 AC 63 ms
29,764 KB
testcase_36 AC 5 ms
4,900 KB
testcase_37 AC 4 ms
4,892 KB
testcase_38 AC 62 ms
34,440 KB
testcase_39 AC 20 ms
13,188 KB
testcase_40 AC 73 ms
31,348 KB
testcase_41 AC 15 ms
10,164 KB
testcase_42 AC 32 ms
20,200 KB
testcase_43 AC 22 ms
14,116 KB
testcase_44 AC 35 ms
21,188 KB
testcase_45 AC 30 ms
19,144 KB
testcase_46 AC 16 ms
10,656 KB
testcase_47 AC 31 ms
20,180 KB
testcase_48 AC 37 ms
23,168 KB
testcase_49 AC 70 ms
31,356 KB
testcase_50 AC 47 ms
26,988 KB
testcase_51 AC 44 ms
24,496 KB
testcase_52 AC 9 ms
7,480 KB
testcase_53 AC 12 ms
9,344 KB
testcase_54 AC 50 ms
29,940 KB
testcase_55 AC 18 ms
10,976 KB
testcase_56 AC 69 ms
37,064 KB
testcase_57 AC 58 ms
26,032 KB
testcase_58 AC 97 ms
42,040 KB
testcase_59 AC 81 ms
41,980 KB
testcase_60 AC 84 ms
41,976 KB
testcase_61 AC 65 ms
41,996 KB
testcase_62 AC 64 ms
42,044 KB
testcase_63 AC 1 ms
4,376 KB
testcase_64 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, k; scanf("%d%d", &n, &k); std::vector<int> p(n);
	for(int i = 0; i < n; i++) scanf("%d", &p[i]);

	auto dp = make_v<int>(32, n);
	auto ep = make_v<i64>(32, n);
	for(int i = 0; i < n; i++) dp[0][i] = (i + p[i]) % n;
	for(int i = 0; i < n; i++) ep[0][i] = p[i];
	for(int i = 0; i < 31; i++) {
		for(int j = 0; j < n; j++) {
			dp[i + 1][j] = dp[i][dp[i][j]];
			ep[i + 1][j] = ep[i][j] + ep[i][dp[i][j]];
		}
	}

	for(int i = 0; i < n; i++) {
		i64 ans = i + 1;
		int now = i;
		for(int j = 31; j >= 0; j--) {
			if(!(k >> j & 1)) continue;
			ans += ep[j][now];
			now = dp[j][now];
		}

		printf("%lld\n", ans);
	}
	return 0;
}
0