結果

問題 No.1013 〇マス進む
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2020-09-30 19:17:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 283 ms / 2,000 ms
コード長 980 bytes
コンパイル時間 1,731 ms
コンパイル使用メモリ 172,492 KB
実行使用メモリ 42,064 KB
最終ジャッジ日時 2023-09-20 12:00:14
合計ジャッジ時間 15,443 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 9 ms
4,376 KB
testcase_14 AC 100 ms
21,876 KB
testcase_15 AC 182 ms
33,348 KB
testcase_16 AC 155 ms
30,540 KB
testcase_17 AC 89 ms
19,500 KB
testcase_18 AC 112 ms
22,888 KB
testcase_19 AC 64 ms
14,856 KB
testcase_20 AC 218 ms
40,120 KB
testcase_21 AC 80 ms
17,956 KB
testcase_22 AC 118 ms
23,680 KB
testcase_23 AC 36 ms
10,212 KB
testcase_24 AC 221 ms
41,456 KB
testcase_25 AC 214 ms
40,340 KB
testcase_26 AC 36 ms
9,700 KB
testcase_27 AC 75 ms
17,080 KB
testcase_28 AC 36 ms
9,836 KB
testcase_29 AC 206 ms
39,276 KB
testcase_30 AC 70 ms
15,796 KB
testcase_31 AC 133 ms
27,064 KB
testcase_32 AC 96 ms
20,944 KB
testcase_33 AC 102 ms
21,100 KB
testcase_34 AC 175 ms
31,432 KB
testcase_35 AC 173 ms
29,744 KB
testcase_36 AC 12 ms
5,036 KB
testcase_37 AC 11 ms
4,912 KB
testcase_38 AC 188 ms
34,372 KB
testcase_39 AC 60 ms
13,200 KB
testcase_40 AC 204 ms
31,372 KB
testcase_41 AC 40 ms
9,936 KB
testcase_42 AC 100 ms
20,208 KB
testcase_43 AC 64 ms
14,408 KB
testcase_44 AC 102 ms
21,128 KB
testcase_45 AC 89 ms
19,084 KB
testcase_46 AC 45 ms
10,820 KB
testcase_47 AC 97 ms
20,352 KB
testcase_48 AC 119 ms
23,260 KB
testcase_49 AC 195 ms
31,244 KB
testcase_50 AC 144 ms
27,180 KB
testcase_51 AC 124 ms
24,468 KB
testcase_52 AC 24 ms
7,240 KB
testcase_53 AC 35 ms
9,228 KB
testcase_54 AC 144 ms
29,772 KB
testcase_55 AC 48 ms
11,028 KB
testcase_56 AC 216 ms
36,948 KB
testcase_57 AC 159 ms
26,088 KB
testcase_58 AC 283 ms
42,056 KB
testcase_59 AC 263 ms
42,052 KB
testcase_60 AC 229 ms
41,888 KB
testcase_61 AC 214 ms
42,064 KB
testcase_62 AC 204 ms
41,960 KB
testcase_63 AC 2 ms
4,376 KB
testcase_64 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.09.30 19:17:42
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n,k;cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    vector<vector<int>> next_v(32,vector<int>(n));
    vector<vector<ll>> sum(32,vector<ll>(n));
    for (int i = 0; i < n; i++) {
        next_v[0][i] = (i+p[i])%n;
        sum[0][i] = p[i];
    }
    for (int i = 1; i < 32; i++) {
        for (int j = 0; j < n; j++) {
            next_v[i][j] = next_v[i-1][next_v[i-1][j]];
            sum[i][j] = sum[i-1][j] + sum[i-1][next_v[i-1][j]];
        }
    }
    for (int i = 0; i < n; i++) {
        ll now = i;
        ll ans = i+1;
        for (int j = 0; j < 32; j++) {
            if (k & (1<<j)) {
                ans += sum[j][now];
                now = next_v[j][now];
            }
        }
        cout << ans << endl;
    }
    return 0;
}
0