結果

問題 No.1013 〇マス進む
ユーザー kcvlexkcvlex
提出日時 2020-03-20 22:23:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 3,123 bytes
コンパイル時間 5,099 ms
コンパイル使用メモリ 171,576 KB
実行使用メモリ 56,944 KB
最終ジャッジ日時 2023-08-21 17:08:47
合計ジャッジ時間 6,697 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,936 KB
testcase_01 AC 2 ms
5,188 KB
testcase_02 AC 2 ms
5,004 KB
testcase_03 AC 2 ms
5,000 KB
testcase_04 AC 2 ms
4,940 KB
testcase_05 AC 3 ms
5,000 KB
testcase_06 AC 2 ms
5,008 KB
testcase_07 AC 3 ms
5,004 KB
testcase_08 AC 2 ms
5,004 KB
testcase_09 AC 3 ms
5,008 KB
testcase_10 AC 3 ms
4,940 KB
testcase_11 AC 2 ms
4,936 KB
testcase_12 AC 2 ms
4,936 KB
testcase_13 AC 5 ms
5,508 KB
testcase_14 AC 24 ms
29,136 KB
testcase_15 AC 34 ms
45,044 KB
testcase_16 AC 31 ms
41,312 KB
testcase_17 AC 23 ms
25,824 KB
testcase_18 AC 26 ms
30,816 KB
testcase_19 AC 19 ms
19,624 KB
testcase_20 AC 38 ms
54,328 KB
testcase_21 AC 22 ms
23,964 KB
testcase_22 AC 26 ms
31,884 KB
testcase_23 AC 13 ms
12,488 KB
testcase_24 AC 40 ms
56,248 KB
testcase_25 AC 39 ms
55,028 KB
testcase_26 AC 13 ms
12,696 KB
testcase_27 AC 21 ms
22,964 KB
testcase_28 AC 13 ms
12,668 KB
testcase_29 AC 38 ms
53,288 KB
testcase_30 AC 20 ms
20,616 KB
testcase_31 AC 29 ms
36,484 KB
testcase_32 AC 24 ms
27,924 KB
testcase_33 AC 25 ms
28,084 KB
testcase_34 AC 34 ms
42,572 KB
testcase_35 AC 34 ms
40,480 KB
testcase_36 AC 9 ms
6,296 KB
testcase_37 AC 5 ms
5,952 KB
testcase_38 AC 36 ms
46,748 KB
testcase_39 AC 19 ms
17,124 KB
testcase_40 AC 36 ms
42,448 KB
testcase_41 AC 14 ms
12,840 KB
testcase_42 AC 24 ms
26,868 KB
testcase_43 AC 19 ms
18,424 KB
testcase_44 AC 25 ms
28,040 KB
testcase_45 AC 24 ms
25,108 KB
testcase_46 AC 15 ms
13,892 KB
testcase_47 AC 24 ms
27,028 KB
testcase_48 AC 27 ms
31,396 KB
testcase_49 AC 36 ms
42,120 KB
testcase_50 AC 31 ms
36,372 KB
testcase_51 AC 29 ms
32,828 KB
testcase_52 AC 9 ms
9,216 KB
testcase_53 AC 12 ms
11,680 KB
testcase_54 AC 32 ms
40,488 KB
testcase_55 AC 16 ms
13,980 KB
testcase_56 AC 40 ms
50,328 KB
testcase_57 AC 31 ms
35,052 KB
testcase_58 AC 45 ms
56,920 KB
testcase_59 AC 45 ms
56,820 KB
testcase_60 AC 42 ms
56,944 KB
testcase_61 AC 40 ms
56,816 KB
testcase_62 AC 37 ms
56,856 KB
testcase_63 AC 2 ms
4,936 KB
testcase_64 AC 2 ms
5,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t ...Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t ...Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

const std::size_t SIZE = 1e5 + 10;
mdarray<pll, 32, SIZE> dp;

int main() {
    ll n, k;
    std::cin >> n >> k;
    vec<ll> p(n);
    for (ll i = 0; i < n; i++) {
        std::cin >> p[i];
        p[i]--;
    }

    for (ll i = 0; i < n; i++) {
        ll nxt = i + p[i] + 1;
        dp[0][i] = pll(nxt % n, nxt / n);
    }
    
    for (ll i = 0; i < 32 - 1; i++) {
        for (ll j = 0; j < n; j++) {
            ll a, b, c, d;
            std::tie(a, b) = dp[i][j];
            std::tie(c, d) = dp[i][a];
            dp[i + 1][j] = pll(c, b + d);
        }
    }

    vec<pll> ans(n);
    for (ll i = 0; i < n; i++) ans[i] = pll(i, 0);
    for (ll i = 0; k; i++, k /= 2) {
        if (!(k & 1)) continue;
        auto tmp = std::move(ans);
        ans.resize(n);
        for (ll j = 0; j < n; j++) {
            ll a, b, c, d;
            std::tie(a, b) = tmp[j];
            std::tie(c, d) = dp[i][a];
            ans[j] = pll(c, b + d);
        }
    }

    for (ll i = 0; i < n; i++) {
        ll a, b;
        std::tie(a, b) = ans[i];
        std::cout << b * n + a + 1 << '\n';
    }
    return 0;
}
0