結果

問題 No.1013 〇マス進む
ユーザー Y17Y17
提出日時 2020-03-20 22:19:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 927 bytes
コンパイル時間 1,548 ms
コンパイル使用メモリ 166,824 KB
実行使用メモリ 82,520 KB
最終ジャッジ日時 2023-08-21 17:04:14
合計ジャッジ時間 11,744 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
79,124 KB
testcase_01 AC 16 ms
79,216 KB
testcase_02 AC 16 ms
79,284 KB
testcase_03 AC 18 ms
79,404 KB
testcase_04 AC 16 ms
79,112 KB
testcase_05 AC 18 ms
79,292 KB
testcase_06 AC 17 ms
79,176 KB
testcase_07 AC 18 ms
79,144 KB
testcase_08 AC 17 ms
79,420 KB
testcase_09 AC 18 ms
79,180 KB
testcase_10 AC 18 ms
79,132 KB
testcase_11 AC 17 ms
79,408 KB
testcase_12 AC 18 ms
79,452 KB
testcase_13 AC 23 ms
79,312 KB
testcase_14 AC 103 ms
80,700 KB
testcase_15 AC 173 ms
81,404 KB
testcase_16 AC 151 ms
81,240 KB
testcase_17 AC 92 ms
80,608 KB
testcase_18 AC 116 ms
80,812 KB
testcase_19 AC 72 ms
80,288 KB
testcase_20 AC 207 ms
82,156 KB
testcase_21 AC 84 ms
80,480 KB
testcase_22 AC 118 ms
80,872 KB
testcase_23 AC 46 ms
79,816 KB
testcase_24 AC 211 ms
82,204 KB
testcase_25 AC 203 ms
82,112 KB
testcase_26 AC 46 ms
79,820 KB
testcase_27 AC 81 ms
80,424 KB
testcase_28 AC 48 ms
79,828 KB
testcase_29 AC 203 ms
82,008 KB
testcase_30 AC 79 ms
80,368 KB
testcase_31 AC 132 ms
81,132 KB
testcase_32 AC 97 ms
80,812 KB
testcase_33 AC 103 ms
80,812 KB
testcase_34 AC 172 ms
81,300 KB
testcase_35 AC 161 ms
81,196 KB
testcase_36 AC 26 ms
79,340 KB
testcase_37 AC 25 ms
79,288 KB
testcase_38 AC 178 ms
81,512 KB
testcase_39 AC 69 ms
80,136 KB
testcase_40 AC 181 ms
81,332 KB
testcase_41 AC 51 ms
79,800 KB
testcase_42 AC 107 ms
80,616 KB
testcase_43 AC 73 ms
80,192 KB
testcase_44 AC 107 ms
80,672 KB
testcase_45 AC 92 ms
80,532 KB
testcase_46 AC 54 ms
79,912 KB
testcase_47 AC 99 ms
80,612 KB
testcase_48 AC 118 ms
80,836 KB
testcase_49 AC 181 ms
81,300 KB
testcase_50 AC 140 ms
81,028 KB
testcase_51 AC 124 ms
80,860 KB
testcase_52 AC 37 ms
79,596 KB
testcase_53 AC 46 ms
79,716 KB
testcase_54 AC 140 ms
81,300 KB
testcase_55 AC 59 ms
80,188 KB
testcase_56 AC 196 ms
81,824 KB
testcase_57 AC 152 ms
80,992 KB
testcase_58 AC 264 ms
82,520 KB
testcase_59 AC 238 ms
82,340 KB
testcase_60 AC 212 ms
82,340 KB
testcase_61 AC 195 ms
82,388 KB
testcase_62 AC 191 ms
82,276 KB
testcase_63 AC 17 ms
79,136 KB
testcase_64 AC 17 ms
79,148 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