結果

問題 No.1013 〇マス進む
ユーザー bleuloverbluebleuloverblue
提出日時 2020-09-27 15:51:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,520 bytes
コンパイル時間 3,833 ms
コンパイル使用メモリ 230,520 KB
実行使用メモリ 17,392 KB
最終ジャッジ日時 2023-09-13 01:58:01
合計ジャッジ時間 17,094 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 8 ms
4,380 KB
testcase_14 AC 82 ms
9,928 KB
testcase_15 AC 132 ms
14,148 KB
testcase_16 AC 121 ms
13,304 KB
testcase_17 AC 71 ms
9,008 KB
testcase_18 AC 91 ms
10,236 KB
testcase_19 AC 52 ms
7,244 KB
testcase_20 AC 161 ms
16,548 KB
testcase_21 AC 67 ms
8,632 KB
testcase_22 AC 92 ms
10,560 KB
testcase_23 AC 30 ms
5,452 KB
testcase_24 AC 164 ms
16,748 KB
testcase_25 AC 161 ms
16,536 KB
testcase_26 AC 31 ms
5,400 KB
testcase_27 AC 60 ms
8,300 KB
testcase_28 AC 29 ms
5,400 KB
testcase_29 AC 157 ms
16,228 KB
testcase_30 AC 56 ms
7,576 KB
testcase_31 AC 104 ms
11,736 KB
testcase_32 AC 76 ms
9,716 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 RE -
testcase_45 WA -
testcase_46 WA -
testcase_47 RE -
testcase_48 WA -
testcase_49 WA -
testcase_50 RE -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 RE -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 AC 166 ms
17,320 KB
testcase_62 AC 163 ms
17,016 KB
testcase_63 AC 1 ms
4,376 KB
testcase_64 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;
using usize = ::std::size_t;
//using u64 = ::std::int_least64_t;
using u64 = long long;
static constexpr u64 Inf = ::std::numeric_limits<u64>::max() / 2;
int N;
struct Doubling
{
  const int LOG;
  vector< vector< int > > table;
    
  Doubling(int sz, int64_t lim_t) : LOG(64 - __builtin_clzll(lim_t))
  {
    table.assign(LOG, vector< int >(sz, -1));
  }

  void set_next(int k, int x)
  {
    table[0][k] = x;
  }

  void build()
  {
    for(int k = 0; k + 1 < LOG; k++) {
      for(int i = 0; i < table[k].size(); i++) {
        if(table[k][i] == -1) table[k + 1][i] = -1;
        else table[k + 1][i] = table[k][i] + table[k][(i + table[k][i]) % N];
      }
    }
  }

  int query(int k, int64_t t)
  {
      int sum = k + 1;
    for(int i = LOG - 1; i >= 0; i--) {
        if((t >> i) & 1) {
            sum += table[i][k];
            k = (k + table[i][k])%N;
        }
    }
    return sum;
  }
};


int main(int argc, char *argv[])
{
    /*std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());*/
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int K;
    cin >> N >> K;
    vector<int> P(N);
    for (int i = 0; i < N; i++) {
        cin >> P[i];
    }
    Doubling doubling(N, 1e10);
    for (int i = 0; i < N; i++) {
        doubling.set_next(i, P[i]);
    }
    doubling.build();
    for (int i = 0; i < N; i++) {
        cout << doubling.query(i, K) << endl;
    }
    
    return 0;
    
}
0