結果

問題 No.1013 〇マス進む
ユーザー 👑 jupirojupiro
提出日時 2020-03-20 22:21:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 1,849 bytes
コンパイル時間 1,412 ms
コンパイル使用メモリ 116,040 KB
実行使用メモリ 67,320 KB
最終ジャッジ日時 2023-08-21 17:06:04
合計ジャッジ時間 8,006 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 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 5 ms
5,412 KB
testcase_14 AC 45 ms
33,672 KB
testcase_15 AC 79 ms
52,856 KB
testcase_16 AC 69 ms
48,468 KB
testcase_17 AC 38 ms
29,872 KB
testcase_18 AC 50 ms
35,968 KB
testcase_19 AC 29 ms
22,576 KB
testcase_20 AC 96 ms
63,832 KB
testcase_21 AC 35 ms
27,552 KB
testcase_22 AC 53 ms
37,156 KB
testcase_23 AC 16 ms
13,964 KB
testcase_24 AC 98 ms
66,008 KB
testcase_25 AC 96 ms
64,664 KB
testcase_26 AC 17 ms
14,060 KB
testcase_27 AC 33 ms
26,240 KB
testcase_28 AC 16 ms
14,016 KB
testcase_29 AC 91 ms
62,576 KB
testcase_30 AC 31 ms
23,820 KB
testcase_31 AC 59 ms
42,616 KB
testcase_32 AC 42 ms
32,388 KB
testcase_33 AC 45 ms
32,444 KB
testcase_34 AC 83 ms
50,112 KB
testcase_35 AC 86 ms
47,256 KB
testcase_36 AC 6 ms
6,284 KB
testcase_37 AC 5 ms
5,916 KB
testcase_38 AC 90 ms
54,744 KB
testcase_39 AC 29 ms
19,708 KB
testcase_40 AC 101 ms
49,684 KB
testcase_41 AC 19 ms
14,484 KB
testcase_42 AC 46 ms
31,184 KB
testcase_43 AC 29 ms
20,844 KB
testcase_44 AC 48 ms
32,880 KB
testcase_45 AC 41 ms
29,308 KB
testcase_46 AC 21 ms
15,552 KB
testcase_47 AC 43 ms
31,512 KB
testcase_48 AC 53 ms
36,088 KB
testcase_49 AC 103 ms
49,416 KB
testcase_50 AC 67 ms
42,456 KB
testcase_51 AC 60 ms
38,272 KB
testcase_52 AC 12 ms
9,860 KB
testcase_53 AC 16 ms
13,140 KB
testcase_54 AC 64 ms
47,192 KB
testcase_55 AC 24 ms
16,052 KB
testcase_56 AC 103 ms
58,736 KB
testcase_57 AC 82 ms
40,904 KB
testcase_58 AC 146 ms
67,292 KB
testcase_59 AC 131 ms
67,312 KB
testcase_60 AC 115 ms
67,300 KB
testcase_61 AC 100 ms
67,316 KB
testcase_62 AC 91 ms
67,320 KB
testcase_63 AC 1 ms
4,376 KB
testcase_64 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main()
{
    /*
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
   */

    ll N, K; scanf("%lld %lld", &N, &K);
    vector<ll> p(N); for (int i = 0; i < N; i++) scanf("%lld", &p[i]);
    vector<vector<ll>> t(40, vector<ll>(N));
    vector<vector<ll>> t2(40, vector<ll>(N));
    for (ll i = 0; i < N; i++) {
        t[0][i] = (i + p[i]) % N;
        if (i + p[i] >= N) {
            t2[0][i] = 1;
            //cout << i << endl;
        }
    }
    for (ll i = 0; i < 39; i++) {
        for (ll j = 0; j < N; j++) {
            t[i + 1][j] = t[i][t[i][j]];
            t2[i + 1][j] = t2[i][t[i][j]] + t2[i][j];
        }
    }

    for (ll start = 0; start < N; start++) {
        ll now = start;
        ll cnt = 0;
        for (ll i = 0; i < 40; i++) {
            if ((K >> i) & 1) {
                cnt += t2[i][now];
                now = t[i][now];

            }
        }
        printf("%lld\n", now + cnt * N + 1);
    }

    return 0;

}
0