結果

問題 No.1013 〇マス進む
ユーザー f_stshf_stsh
提出日時 2020-09-22 14:51:04
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 1,089 bytes
コンパイル時間 1,506 ms
コンパイル使用メモリ 170,600 KB
実行使用メモリ 28,188 KB
最終ジャッジ日時 2023-09-08 10:34:16
合計ジャッジ時間 10,020 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 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,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 45 ms
15,240 KB
testcase_15 AC 75 ms
22,584 KB
testcase_16 AC 68 ms
20,852 KB
testcase_17 AC 41 ms
13,548 KB
testcase_18 AC 51 ms
15,832 KB
testcase_19 AC 29 ms
10,684 KB
testcase_20 AC 91 ms
26,796 KB
testcase_21 AC 37 ms
12,548 KB
testcase_22 AC 52 ms
16,192 KB
testcase_23 AC 17 ms
7,452 KB
testcase_24 AC 91 ms
27,724 KB
testcase_25 AC 91 ms
27,056 KB
testcase_26 AC 18 ms
7,356 KB
testcase_27 AC 33 ms
12,000 KB
testcase_28 AC 17 ms
7,512 KB
testcase_29 AC 87 ms
26,396 KB
testcase_30 AC 32 ms
10,956 KB
testcase_31 AC 60 ms
18,688 KB
testcase_32 AC 41 ms
14,644 KB
testcase_33 AC 50 ms
14,656 KB
testcase_34 AC 81 ms
21,244 KB
testcase_35 AC 86 ms
20,276 KB
testcase_36 AC 7 ms
4,424 KB
testcase_37 AC 6 ms
4,376 KB
testcase_38 AC 89 ms
23,300 KB
testcase_39 AC 32 ms
9,584 KB
testcase_40 AC 96 ms
21,380 KB
testcase_41 AC 23 ms
7,456 KB
testcase_42 AC 53 ms
14,108 KB
testcase_43 AC 33 ms
10,292 KB
testcase_44 AC 53 ms
14,648 KB
testcase_45 AC 49 ms
13,332 KB
testcase_46 AC 25 ms
8,008 KB
testcase_47 AC 48 ms
14,144 KB
testcase_48 AC 57 ms
16,028 KB
testcase_49 AC 96 ms
21,324 KB
testcase_50 AC 71 ms
18,672 KB
testcase_51 AC 66 ms
16,824 KB
testcase_52 AC 14 ms
5,952 KB
testcase_53 AC 19 ms
6,940 KB
testcase_54 AC 77 ms
20,280 KB
testcase_55 AC 28 ms
8,228 KB
testcase_56 AC 112 ms
24,812 KB
testcase_57 AC 80 ms
18,116 KB
testcase_58 AC 131 ms
28,112 KB
testcase_59 AC 125 ms
28,188 KB
testcase_60 AC 119 ms
28,064 KB
testcase_61 AC 91 ms
28,076 KB
testcase_62 AC 87 ms
28,124 KB
testcase_63 AC 1 ms
4,380 KB
testcase_64 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int MOD = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
void solve_dubling() {
    int n, k;
    cin >> n >> k;
    int MAXD = log2(1e+9 + 5);
    // init
    vector<ll> a(n + 1);
    vector<vector<ll>> sum(MAXD + 1, vector<ll>(n + 1, 0));
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum[0][i] = a[i];
    }
    // build
    for (int d = 0; d < MAXD; d++) {
        for (int st = 0; st < n; st++) {
            sum[d + 1][st] = sum[d][st] + sum[d][(st + sum[d][st]) % n];
        }
    }
    // query
    for (int st = 0; st < n; st++) {
        ll ret = st;
        for (int d = MAXD; d >= 0; d--) {
            int b = 1 << d;
            if (k & b) {
                ret += sum[d][ret % n];
            }
        }
        cout << ret + 1 << '\n';
    }

}
/* main */
int main(){
    solve_dubling();
}
0