結果
問題 | No.1013 〇マス進む |
ユーザー | kcvlex |
提出日時 | 2020-03-20 22:23:09 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 3,123 bytes |
コンパイル時間 | 1,567 ms |
コンパイル使用メモリ | 174,668 KB |
実行使用メモリ | 57,188 KB |
最終ジャッジ日時 | 2024-05-08 22:39:43 |
合計ジャッジ時間 | 6,475 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | 2 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 | 3 ms
5,632 KB |
testcase_14 | AC | 26 ms
29,184 KB |
testcase_15 | AC | 35 ms
45,260 KB |
testcase_16 | AC | 34 ms
41,484 KB |
testcase_17 | AC | 25 ms
25,820 KB |
testcase_18 | AC | 28 ms
30,976 KB |
testcase_19 | AC | 20 ms
19,796 KB |
testcase_20 | AC | 41 ms
54,420 KB |
testcase_21 | AC | 23 ms
24,076 KB |
testcase_22 | AC | 29 ms
31,888 KB |
testcase_23 | AC | 10 ms
12,528 KB |
testcase_24 | AC | 41 ms
56,332 KB |
testcase_25 | AC | 42 ms
54,992 KB |
testcase_26 | AC | 11 ms
12,572 KB |
testcase_27 | AC | 22 ms
22,828 KB |
testcase_28 | AC | 11 ms
12,708 KB |
testcase_29 | AC | 40 ms
53,428 KB |
testcase_30 | AC | 21 ms
20,736 KB |
testcase_31 | AC | 31 ms
36,480 KB |
testcase_32 | AC | 26 ms
28,160 KB |
testcase_33 | AC | 27 ms
28,128 KB |
testcase_34 | AC | 36 ms
42,684 KB |
testcase_35 | AC | 36 ms
40,496 KB |
testcase_36 | AC | 4 ms
6,144 KB |
testcase_37 | AC | 5 ms
6,144 KB |
testcase_38 | AC | 39 ms
46,700 KB |
testcase_39 | AC | 17 ms
17,296 KB |
testcase_40 | AC | 38 ms
42,504 KB |
testcase_41 | AC | 12 ms
12,876 KB |
testcase_42 | AC | 26 ms
27,024 KB |
testcase_43 | AC | 19 ms
18,420 KB |
testcase_44 | AC | 30 ms
28,316 KB |
testcase_45 | AC | 25 ms
25,156 KB |
testcase_46 | AC | 13 ms
13,816 KB |
testcase_47 | AC | 26 ms
26,968 KB |
testcase_48 | AC | 29 ms
31,256 KB |
testcase_49 | AC | 37 ms
42,368 KB |
testcase_50 | AC | 33 ms
36,480 KB |
testcase_51 | AC | 31 ms
33,152 KB |
testcase_52 | AC | 8 ms
9,272 KB |
testcase_53 | AC | 11 ms
11,904 KB |
testcase_54 | AC | 34 ms
40,464 KB |
testcase_55 | AC | 15 ms
14,336 KB |
testcase_56 | AC | 42 ms
50,212 KB |
testcase_57 | AC | 33 ms
35,200 KB |
testcase_58 | AC | 47 ms
57,188 KB |
testcase_59 | AC | 48 ms
57,056 KB |
testcase_60 | AC | 45 ms
57,052 KB |
testcase_61 | AC | 42 ms
57,180 KB |
testcase_62 | AC | 38 ms
56,960 KB |
testcase_63 | AC | 2 ms
5,376 KB |
testcase_64 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> #define ALL(v) std::begin(v), std::end(v) #define ALLR(v) std::rbegin(v), std::rend(v) using ll = std::int64_t; using ull = std::uint64_t; using pii = std::pair<int, int>; using tii = std::tuple<int, int, int>; using pll = std::pair<ll, ll>; using tll = std::tuple<ll, ll, ll>; template <typename T> using vec = std::vector<T>; template <typename T> using vvec = vec<vec<T>>; template <typename T> const T& var_min(const T &t) { return t; } template <typename T> const T& var_max(const T &t) { return t; } template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); } template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); } template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); } template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); } template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); } template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); } template <typename T> T make_v(T init) { return init; } template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); } template <typename T, std::size_t Head, std::size_t ...Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; }; template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; }; template <typename T, std::size_t ...Args> using mdarray = typename multi_dem_array<T, Args...>::type; namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; } const std::size_t SIZE = 1e5 + 10; mdarray<pll, 32, SIZE> dp; int main() { ll n, k; std::cin >> n >> k; vec<ll> p(n); for (ll i = 0; i < n; i++) { std::cin >> p[i]; p[i]--; } for (ll i = 0; i < n; i++) { ll nxt = i + p[i] + 1; dp[0][i] = pll(nxt % n, nxt / n); } for (ll i = 0; i < 32 - 1; i++) { for (ll j = 0; j < n; j++) { ll a, b, c, d; std::tie(a, b) = dp[i][j]; std::tie(c, d) = dp[i][a]; dp[i + 1][j] = pll(c, b + d); } } vec<pll> ans(n); for (ll i = 0; i < n; i++) ans[i] = pll(i, 0); for (ll i = 0; k; i++, k /= 2) { if (!(k & 1)) continue; auto tmp = std::move(ans); ans.resize(n); for (ll j = 0; j < n; j++) { ll a, b, c, d; std::tie(a, b) = tmp[j]; std::tie(c, d) = dp[i][a]; ans[j] = pll(c, b + d); } } for (ll i = 0; i < n; i++) { ll a, b; std::tie(a, b) = ans[i]; std::cout << b * n + a + 1 << '\n'; } return 0; }