結果

問題 No.1013 〇マス進む
ユーザー 👑 jupirojupiro
提出日時 2020-03-20 22:21:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 1,849 bytes
コンパイル時間 1,201 ms
コンパイル使用メモリ 117,516 KB
実行使用メモリ 67,676 KB
最終ジャッジ日時 2024-05-08 22:36:39
合計ジャッジ時間 7,825 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 5 ms
5,632 KB
testcase_14 AC 48 ms
34,052 KB
testcase_15 AC 93 ms
53,036 KB
testcase_16 AC 77 ms
48,724 KB
testcase_17 AC 41 ms
30,036 KB
testcase_18 AC 56 ms
36,184 KB
testcase_19 AC 33 ms
22,848 KB
testcase_20 AC 112 ms
64,244 KB
testcase_21 AC 38 ms
27,864 KB
testcase_22 AC 58 ms
37,352 KB
testcase_23 AC 17 ms
14,464 KB
testcase_24 AC 110 ms
66,252 KB
testcase_25 AC 110 ms
64,824 KB
testcase_26 AC 19 ms
14,336 KB
testcase_27 AC 35 ms
26,564 KB
testcase_28 AC 18 ms
14,464 KB
testcase_29 AC 105 ms
62,944 KB
testcase_30 AC 34 ms
23,972 KB
testcase_31 AC 66 ms
42,832 KB
testcase_32 AC 44 ms
32,756 KB
testcase_33 AC 48 ms
32,756 KB
testcase_34 AC 92 ms
50,148 KB
testcase_35 AC 98 ms
47,560 KB
testcase_36 AC 7 ms
6,400 KB
testcase_37 AC 7 ms
6,272 KB
testcase_38 AC 99 ms
55,048 KB
testcase_39 AC 32 ms
19,960 KB
testcase_40 AC 116 ms
49,860 KB
testcase_41 AC 21 ms
14,720 KB
testcase_42 AC 50 ms
31,460 KB
testcase_43 AC 31 ms
21,248 KB
testcase_44 AC 53 ms
33,048 KB
testcase_45 AC 46 ms
29,448 KB
testcase_46 AC 23 ms
15,744 KB
testcase_47 AC 47 ms
31,460 KB
testcase_48 AC 59 ms
36,456 KB
testcase_49 AC 114 ms
49,608 KB
testcase_50 AC 73 ms
42,828 KB
testcase_51 AC 66 ms
38,776 KB
testcase_52 AC 12 ms
10,240 KB
testcase_53 AC 18 ms
13,440 KB
testcase_54 AC 69 ms
47,268 KB
testcase_55 AC 25 ms
16,368 KB
testcase_56 AC 115 ms
59,060 KB
testcase_57 AC 93 ms
41,240 KB
testcase_58 AC 167 ms
67,676 KB
testcase_59 AC 146 ms
67,552 KB
testcase_60 AC 120 ms
67,676 KB
testcase_61 AC 102 ms
67,548 KB
testcase_62 AC 94 ms
67,548 KB
testcase_63 AC 2 ms
5,376 KB
testcase_64 AC 2 ms
5,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