結果

問題 No.1013 〇マス進む
ユーザー furafura
提出日時 2020-10-06 17:48:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 1,944 ms
コンパイル使用メモリ 205,644 KB
実行使用メモリ 27,864 KB
最終ジャッジ日時 2023-09-27 08:00:40
合計ジャッジ時間 7,391 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 3 ms
4,376 KB
testcase_14 AC 24 ms
14,960 KB
testcase_15 AC 43 ms
22,312 KB
testcase_16 AC 37 ms
20,580 KB
testcase_17 AC 22 ms
13,380 KB
testcase_18 AC 30 ms
15,756 KB
testcase_19 AC 17 ms
10,704 KB
testcase_20 AC 52 ms
26,484 KB
testcase_21 AC 19 ms
12,636 KB
testcase_22 AC 29 ms
16,356 KB
testcase_23 AC 9 ms
7,424 KB
testcase_24 AC 54 ms
27,376 KB
testcase_25 AC 51 ms
26,900 KB
testcase_26 AC 10 ms
7,424 KB
testcase_27 AC 18 ms
12,108 KB
testcase_28 AC 9 ms
7,308 KB
testcase_29 AC 49 ms
25,944 KB
testcase_30 AC 17 ms
11,004 KB
testcase_31 AC 32 ms
18,396 KB
testcase_32 AC 22 ms
14,488 KB
testcase_33 AC 25 ms
14,332 KB
testcase_34 AC 45 ms
21,036 KB
testcase_35 AC 48 ms
19,872 KB
testcase_36 AC 5 ms
4,376 KB
testcase_37 AC 4 ms
4,376 KB
testcase_38 AC 51 ms
22,948 KB
testcase_39 AC 18 ms
9,372 KB
testcase_40 AC 58 ms
21,000 KB
testcase_41 AC 13 ms
7,576 KB
testcase_42 AC 28 ms
13,908 KB
testcase_43 AC 18 ms
9,908 KB
testcase_44 AC 28 ms
14,484 KB
testcase_45 AC 26 ms
13,116 KB
testcase_46 AC 13 ms
7,864 KB
testcase_47 AC 25 ms
13,864 KB
testcase_48 AC 31 ms
15,704 KB
testcase_49 AC 58 ms
21,088 KB
testcase_50 AC 38 ms
18,408 KB
testcase_51 AC 34 ms
16,884 KB
testcase_52 AC 8 ms
5,776 KB
testcase_53 AC 10 ms
7,004 KB
testcase_54 AC 39 ms
20,052 KB
testcase_55 AC 14 ms
8,100 KB
testcase_56 AC 60 ms
24,372 KB
testcase_57 AC 46 ms
17,508 KB
testcase_58 AC 83 ms
27,528 KB
testcase_59 AC 76 ms
27,584 KB
testcase_60 AC 61 ms
27,588 KB
testcase_61 AC 49 ms
27,600 KB
testcase_62 AC 46 ms
27,864 KB
testcase_63 AC 1 ms
4,376 KB
testcase_64 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<int> p(n);
	rep(i,n) scanf("%d",&p[i]);

	vector dbl(30,vector<pair<int,int>>(n));
	rep(i,n){
		if(i+p[i]<n) dbl[0][i]={i+p[i],0};
		else         dbl[0][i]={(i+p[i]-n),1};
	}
	for(int t=1;t<30;t++){
		rep(i,n){
			auto [i1,c1]=dbl[t-1][i];
			auto [i2,c2]=dbl[t-1][i1];
			dbl[t][i]={i2,c1+c2};
		}
	}

	rep(i,n){
		lint x=i,c=0;
		rep(t,30) if(k>>t&1) {
			c+=dbl[t][x].second;
			x=dbl[t][x].first;
		}
		printf("%lld\n",x+n*c+1);
	}

	return 0;
}
0