結果
問題 | No.1013 〇マス進む |
ユーザー | 👑 potato167 |
提出日時 | 2024-09-09 17:12:02 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 97 ms / 2,000 ms |
コード長 | 2,683 bytes |
コンパイル時間 | 1,187 ms |
コンパイル使用メモリ | 88,572 KB |
実行使用メモリ | 40,832 KB |
最終ジャッジ日時 | 2024-09-09 17:12:10 |
合計ジャッジ時間 | 7,904 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 3 ms
6,944 KB |
testcase_14 | AC | 17 ms
9,856 KB |
testcase_15 | AC | 30 ms
13,184 KB |
testcase_16 | AC | 27 ms
13,184 KB |
testcase_17 | AC | 15 ms
8,704 KB |
testcase_18 | AC | 21 ms
10,368 KB |
testcase_19 | AC | 11 ms
6,944 KB |
testcase_20 | AC | 33 ms
13,184 KB |
testcase_21 | AC | 14 ms
8,576 KB |
testcase_22 | AC | 20 ms
9,984 KB |
testcase_23 | AC | 7 ms
6,944 KB |
testcase_24 | AC | 37 ms
16,896 KB |
testcase_25 | AC | 35 ms
15,488 KB |
testcase_26 | AC | 8 ms
6,940 KB |
testcase_27 | AC | 12 ms
7,936 KB |
testcase_28 | AC | 7 ms
6,940 KB |
testcase_29 | AC | 32 ms
14,080 KB |
testcase_30 | AC | 13 ms
7,680 KB |
testcase_31 | AC | 24 ms
11,904 KB |
testcase_32 | AC | 15 ms
9,728 KB |
testcase_33 | AC | 30 ms
20,352 KB |
testcase_34 | AC | 51 ms
28,160 KB |
testcase_35 | AC | 60 ms
28,288 KB |
testcase_36 | AC | 5 ms
6,940 KB |
testcase_37 | AC | 5 ms
6,940 KB |
testcase_38 | AC | 57 ms
31,616 KB |
testcase_39 | AC | 19 ms
12,288 KB |
testcase_40 | AC | 70 ms
29,568 KB |
testcase_41 | AC | 14 ms
9,856 KB |
testcase_42 | AC | 31 ms
18,560 KB |
testcase_43 | AC | 18 ms
12,416 KB |
testcase_44 | AC | 32 ms
20,736 KB |
testcase_45 | AC | 28 ms
18,048 KB |
testcase_46 | AC | 15 ms
10,496 KB |
testcase_47 | AC | 27 ms
17,024 KB |
testcase_48 | AC | 33 ms
20,736 KB |
testcase_49 | AC | 67 ms
27,776 KB |
testcase_50 | AC | 45 ms
26,368 KB |
testcase_51 | AC | 38 ms
22,016 KB |
testcase_52 | AC | 9 ms
7,296 KB |
testcase_53 | AC | 12 ms
9,088 KB |
testcase_54 | AC | 44 ms
28,800 KB |
testcase_55 | AC | 16 ms
10,880 KB |
testcase_56 | AC | 74 ms
35,840 KB |
testcase_57 | AC | 57 ms
25,472 KB |
testcase_58 | AC | 97 ms
39,552 KB |
testcase_59 | AC | 87 ms
40,832 KB |
testcase_60 | AC | 75 ms
40,704 KB |
testcase_61 | AC | 31 ms
13,824 KB |
testcase_62 | AC | 21 ms
6,940 KB |
testcase_63 | AC | 2 ms
6,944 KB |
testcase_64 | AC | 2 ms
6,940 KB |
ソースコード
#include <vector> #include <cassert> namespace po167{ template<class T, T(*op)(T, T)> struct Doubling_op{ int n; int depth; std::vector<std::vector<int>> index; std::vector<std::vector<T>> val; Doubling_op(std::vector<int> p, std::vector<T> v, long long lim = (1ll << 60) - 1){ n = p.size(); for (auto x : p) assert(0 <= x && x < n); assert(n == (int)v.size()); depth = 1; while ((1ll << depth) <= lim) depth++; index.resize(depth); val.resize(depth); index[0] = p; val[0] = v; for (int i = 1; i < depth; i++){ index[i].resize(n); val[i].resize(n); for (int j = 0; j < n; j++){ int tmp = index[i - 1][j]; index[i][j] = index[i - 1][tmp]; val[i][j] = op(val[i - 1][j], val[i - 1][tmp]); } } } std::pair<int, T> query(int start_ind, T start_val, long long times){ assert(0 <= times && times < (1ll << depth)); int i = 0; while (times){ if (times & 1){ start_val = op(start_val, val[i][start_ind]); start_ind = index[i][start_ind]; } i++; times >>= 1; } return std::make_pair(start_ind, start_val); } }; struct Doubling{ int n; int depth; std::vector<std::vector<int>> index; Doubling(std::vector<int> p, long long lim = (1ll << 60) - 1){ n = p.size(); for (auto x : p) assert(0 <= x && x < n); depth = 1; while ((1ll << depth) <= lim) depth++; index.resize(depth); index[0] = p; for (int i = 1; i < depth; i++){ index[i].resize(n); for (int j = 0; j < n; j++){ index[i][j] = index[i - 1][index[i - 1][j]]; } } } int query(int ind, long long times){ assert(0 <= times && times < (1ll << depth)); int i = 0; while (times){ if (times) ind = index[i][ind]; i++; times >>= 1; } return ind; } }; } long long op(long long a, long long b){ return a + b; } #include <iostream> int main(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int N, K; std::cin >> N >> K; std::vector<long long> P(N); std::vector<int> Q(N); for (int i = 0; i < N; i++){ std::cin >> P[i]; Q[i] = (i + P[i]); if (Q[i] >= N) Q[i] -= N; } po167::Doubling_op<long long, op> D(Q, P, K); for (int i = 0; i < N; i++){ std::cout << D.query(i, i + 1, K).second << "\n"; } }