結果

問題 No.1013 〇マス進む
ユーザー merom686
提出日時 2020-03-20 22:34:06
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 758 bytes
コンパイル時間 759 ms
コンパイル使用メモリ 78,432 KB
実行使用メモリ 27,520 KB
最終ジャッジ日時 2024-12-15 06:53:01
合計ジャッジ時間 6,635 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 62
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    vector<vector<ll>> p(30, vector<ll>(n));
    for (int i = 0; i < n; i++) {
        cin >> p[0][i];
    }

    for (int j = 0; j < 30 - 1; j++) {
        for (int i = 0; i < n; i++) {
            ll t = p[j][i];
            p[j + 1][i] = t + p[j][(i + t) % n];
        }
    }

    for (int i = 0; i < n; i++) {
        ll s = i;
        for (int j = 30 - 1; j >= 0; j--) {
            if (k & 1 << j) s += p[j][s % n];
        }
        cout << s + 1 << '\n';
    }

    return 0;
}
0