結果

問題 No.1013 〇マス進む
ユーザー kappybarkappybar
提出日時 2020-07-10 16:42:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 307 ms / 2,000 ms
コード長 1,200 bytes
コンパイル時間 1,643 ms
コンパイル使用メモリ 170,956 KB
実行使用メモリ 162,244 KB
最終ジャッジ日時 2024-04-19 07:48:27
合計ジャッジ時間 14,180 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 4 ms
6,944 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 4 ms
6,940 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 4 ms
6,944 KB
testcase_13 AC 12 ms
9,216 KB
testcase_14 AC 145 ms
79,232 KB
testcase_15 AC 235 ms
126,360 KB
testcase_16 AC 216 ms
115,712 KB
testcase_17 AC 127 ms
69,376 KB
testcase_18 AC 157 ms
84,568 KB
testcase_19 AC 90 ms
51,584 KB
testcase_20 AC 292 ms
153,856 KB
testcase_21 AC 116 ms
64,128 KB
testcase_22 AC 161 ms
87,508 KB
testcase_23 AC 52 ms
30,592 KB
testcase_24 AC 298 ms
159,304 KB
testcase_25 AC 292 ms
155,648 KB
testcase_26 AC 52 ms
30,464 KB
testcase_27 AC 113 ms
60,996 KB
testcase_28 AC 52 ms
30,868 KB
testcase_29 AC 281 ms
150,604 KB
testcase_30 AC 96 ms
54,400 KB
testcase_31 AC 192 ms
101,248 KB
testcase_32 AC 138 ms
76,032 KB
testcase_33 AC 141 ms
76,128 KB
testcase_34 AC 222 ms
119,296 KB
testcase_35 AC 212 ms
112,836 KB
testcase_36 AC 16 ms
11,264 KB
testcase_37 AC 15 ms
10,752 KB
testcase_38 AC 245 ms
131,072 KB
testcase_39 AC 79 ms
44,380 KB
testcase_40 AC 228 ms
118,548 KB
testcase_41 AC 54 ms
31,268 KB
testcase_42 AC 136 ms
73,088 KB
testcase_43 AC 87 ms
48,004 KB
testcase_44 AC 144 ms
76,676 KB
testcase_45 AC 126 ms
67,960 KB
testcase_46 AC 59 ms
34,128 KB
testcase_47 AC 137 ms
72,704 KB
testcase_48 AC 158 ms
85,248 KB
testcase_49 AC 225 ms
118,144 KB
testcase_50 AC 191 ms
101,248 KB
testcase_51 AC 167 ms
90,880 KB
testcase_52 AC 34 ms
20,736 KB
testcase_53 AC 47 ms
28,544 KB
testcase_54 AC 211 ms
112,160 KB
testcase_55 AC 61 ms
35,328 KB
testcase_56 AC 266 ms
141,440 KB
testcase_57 AC 189 ms
97,028 KB
testcase_58 AC 305 ms
161,920 KB
testcase_59 AC 307 ms
162,244 KB
testcase_60 AC 307 ms
162,116 KB
testcase_61 AC 302 ms
161,988 KB
testcase_62 AC 303 ms
162,120 KB
testcase_63 AC 2 ms
6,940 KB
testcase_64 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> p(n);
    rep(i,n) cin >> p[i];
    vector<vector<pll>> db(100,vector<pll>(n));
    rep(i,n) db[0][i] = {(i+p[i])%n,(i+p[i])/n};
    for(int i=1;i<=99;i++){
        rep(j,n){
            ll a = db[i-1][j].first;
            ll b = db[i-1][j].second + db[i-1][a].second;
            a = db[i-1][a].first;
            db[i][j] = pll(a,b);
        }
    }

    vector<pll> ans(n);
    rep(i,n) ans[i] = pll(i,0);
    ll c = 0;
    while(k > 0){
        if(k&1){
            rep(i,n){
                ll a = ans[i].first;
                ll b = ans[i].second + db[c][a].second;
                a = db[c][a].first;
                ans[i] = pll(a,b);
            }
        }
        k >>= 1;
        ++c;
    }
    rep(i,n){
        ll now = ans[i].first + ans[i].second * n + 1 ; 
        cout << now << endl;
    }
    return 0;
}
0