結果

問題 No.1013 〇マス進む
ユーザー rniyarniya
提出日時 2020-03-20 22:06:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 816 bytes
コンパイル時間 1,560 ms
コンパイル使用メモリ 170,276 KB
実行使用メモリ 51,912 KB
最終ジャッジ日時 2023-08-21 16:46:49
合計ジャッジ時間 7,553 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 4 ms
4,840 KB
testcase_14 AC 33 ms
26,564 KB
testcase_15 AC 59 ms
41,120 KB
testcase_16 AC 51 ms
37,640 KB
testcase_17 AC 29 ms
23,400 KB
testcase_18 AC 39 ms
28,084 KB
testcase_19 AC 22 ms
17,856 KB
testcase_20 AC 69 ms
49,464 KB
testcase_21 AC 25 ms
21,808 KB
testcase_22 AC 38 ms
28,932 KB
testcase_23 AC 11 ms
11,436 KB
testcase_24 AC 69 ms
51,068 KB
testcase_25 AC 71 ms
50,040 KB
testcase_26 AC 13 ms
11,424 KB
testcase_27 AC 23 ms
20,780 KB
testcase_28 AC 12 ms
11,452 KB
testcase_29 AC 64 ms
48,408 KB
testcase_30 AC 23 ms
18,916 KB
testcase_31 AC 42 ms
33,208 KB
testcase_32 AC 30 ms
25,436 KB
testcase_33 AC 32 ms
25,480 KB
testcase_34 AC 62 ms
38,636 KB
testcase_35 AC 67 ms
36,856 KB
testcase_36 AC 5 ms
5,420 KB
testcase_37 AC 4 ms
5,272 KB
testcase_38 AC 68 ms
42,340 KB
testcase_39 AC 22 ms
15,780 KB
testcase_40 AC 77 ms
38,792 KB
testcase_41 AC 15 ms
11,752 KB
testcase_42 AC 35 ms
24,804 KB
testcase_43 AC 22 ms
16,796 KB
testcase_44 AC 36 ms
25,704 KB
testcase_45 AC 31 ms
22,812 KB
testcase_46 AC 17 ms
12,604 KB
testcase_47 AC 32 ms
24,428 KB
testcase_48 AC 41 ms
28,340 KB
testcase_49 AC 78 ms
38,468 KB
testcase_50 AC 52 ms
33,248 KB
testcase_51 AC 46 ms
30,000 KB
testcase_52 AC 10 ms
8,324 KB
testcase_53 AC 14 ms
10,760 KB
testcase_54 AC 48 ms
36,580 KB
testcase_55 AC 19 ms
12,896 KB
testcase_56 AC 77 ms
45,496 KB
testcase_57 AC 63 ms
31,760 KB
testcase_58 AC 111 ms
51,912 KB
testcase_59 AC 96 ms
51,808 KB
testcase_60 AC 79 ms
51,840 KB
testcase_61 AC 66 ms
51,884 KB
testcase_62 AC 62 ms
51,880 KB
testcase_63 AC 1 ms
4,380 KB
testcase_64 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const int MAX_LOG=30;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K; cin >> N >> K;
    vector<int> P(N);
    for (int i=0;i<N;++i) cin >> P[i];
    vector<vector<pair<ll,ll>>> doubling(MAX_LOG,vector<pair<ll,ll>>(N));
    for (int i=0;i<N;++i) doubling[0][i]={(i+P[i])%N,(i+P[i])/N};
    for (int j=0;j<MAX_LOG-1;++j)
        for (int i=0;i<N;++i)
            doubling[j+1][i]={doubling[j][doubling[j][i].first].first,doubling[j][i].second+doubling[j][doubling[j][i].first].second};
    for (int i=0;i<N;++i){
        ll now=i,cnt=0;
        for (int j=0;j<MAX_LOG;++j) if (K&1<<j){
            cnt+=doubling[j][now].second;
            now=doubling[j][now].first;
        }
        cout << now+1+cnt*N << '\n';
    }
}
0