結果

問題 No.1013 〇マス進む
ユーザー Y17Y17
提出日時 2020-03-20 22:19:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 261 ms / 2,000 ms
コード長 927 bytes
コンパイル時間 1,600 ms
コンパイル使用メモリ 168,076 KB
実行使用メモリ 82,432 KB
最終ジャッジ日時 2024-05-08 22:32:28
合計ジャッジ時間 11,310 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 4 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 10 ms
6,528 KB
testcase_14 AC 108 ms
41,344 KB
testcase_15 AC 180 ms
64,768 KB
testcase_16 AC 163 ms
59,520 KB
testcase_17 AC 95 ms
36,480 KB
testcase_18 AC 120 ms
44,032 KB
testcase_19 AC 74 ms
27,520 KB
testcase_20 AC 214 ms
78,464 KB
testcase_21 AC 90 ms
33,792 KB
testcase_22 AC 122 ms
45,440 KB
testcase_23 AC 44 ms
17,152 KB
testcase_24 AC 219 ms
81,152 KB
testcase_25 AC 208 ms
79,360 KB
testcase_26 AC 43 ms
17,152 KB
testcase_27 AC 83 ms
32,256 KB
testcase_28 AC 42 ms
17,280 KB
testcase_29 AC 202 ms
76,800 KB
testcase_30 AC 80 ms
29,056 KB
testcase_31 AC 139 ms
52,224 KB
testcase_32 AC 101 ms
39,808 KB
testcase_33 AC 109 ms
39,808 KB
testcase_34 AC 176 ms
61,440 KB
testcase_35 AC 170 ms
57,984 KB
testcase_36 AC 14 ms
7,424 KB
testcase_37 AC 13 ms
7,296 KB
testcase_38 AC 190 ms
67,200 KB
testcase_39 AC 73 ms
24,064 KB
testcase_40 AC 201 ms
61,184 KB
testcase_41 AC 46 ms
17,536 KB
testcase_42 AC 109 ms
38,272 KB
testcase_43 AC 73 ms
25,728 KB
testcase_44 AC 120 ms
40,192 KB
testcase_45 AC 101 ms
35,712 KB
testcase_46 AC 52 ms
18,944 KB
testcase_47 AC 103 ms
38,016 KB
testcase_48 AC 125 ms
44,416 KB
testcase_49 AC 190 ms
60,544 KB
testcase_50 AC 146 ms
52,096 KB
testcase_51 AC 129 ms
47,104 KB
testcase_52 AC 28 ms
12,160 KB
testcase_53 AC 42 ms
16,256 KB
testcase_54 AC 146 ms
57,600 KB
testcase_55 AC 61 ms
19,328 KB
testcase_56 AC 205 ms
72,320 KB
testcase_57 AC 155 ms
50,304 KB
testcase_58 AC 261 ms
82,432 KB
testcase_59 AC 246 ms
82,432 KB
testcase_60 AC 217 ms
82,232 KB
testcase_61 AC 205 ms
82,432 KB
testcase_62 AC 199 ms
82,420 KB
testcase_63 AC 3 ms
5,376 KB
testcase_64 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int n, k;
int p[100010];

pair<int, int> Next[50][100010] = {};

signed main(){
	cin >> n >> k;

	for(int i = 0;i < n;i++){
		cin >> p[i];
	}

	for(int i = 0;i < n;i++){
		Next[0][i] = {(i+p[i]) % n, (i+p[i]) >= n ? 1 : 0};
	}

	for(int b = 1;b < 50;b++){
		for(int i = 0;i <= n;i++){
			pair<int, int> x = Next[b-1][i];
			pair<int, int> y = Next[b-1][x.first];
			pair<int, int> ans = {y.first, x.second + y.second};
			Next[b][i] = ans; 
		}
	}

	for(int i = 0;i < n;i++){
		int ans = 0;
		int now = i;
		for(int b = 0;b < 50;b++){
			if(k & (1ll << b)){
				ans += Next[b][now].second;
				now = Next[b][now].first;
			}
		}
		cout << ans*n + now + 1 << endl;
	}

	return 0;
}
0