結果
問題 | No.1013 〇マス進む |
ユーザー | kcvlex |
提出日時 | 2020-03-20 22:23:08 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 3,123 bytes |
コンパイル時間 | 1,930 ms |
コンパイル使用メモリ | 174,672 KB |
実行使用メモリ | 57,184 KB |
最終ジャッジ日時 | 2024-05-08 22:39:10 |
合計ジャッジ時間 | 6,573 ms |
ジャッジサーバーID (参考情報) |
judge1 / 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 | 3 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 | 3 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 3 ms
5,376 KB |
testcase_13 | AC | 4 ms
5,504 KB |
testcase_14 | AC | 26 ms
29,032 KB |
testcase_15 | AC | 36 ms
45,128 KB |
testcase_16 | AC | 34 ms
41,356 KB |
testcase_17 | AC | 24 ms
25,824 KB |
testcase_18 | AC | 27 ms
31,072 KB |
testcase_19 | AC | 21 ms
19,668 KB |
testcase_20 | AC | 43 ms
54,544 KB |
testcase_21 | AC | 23 ms
23,948 KB |
testcase_22 | AC | 29 ms
31,892 KB |
testcase_23 | AC | 12 ms
12,652 KB |
testcase_24 | AC | 43 ms
56,328 KB |
testcase_25 | AC | 42 ms
54,996 KB |
testcase_26 | AC | 12 ms
12,700 KB |
testcase_27 | AC | 22 ms
22,704 KB |
testcase_28 | AC | 12 ms
12,708 KB |
testcase_29 | AC | 40 ms
53,560 KB |
testcase_30 | AC | 22 ms
20,768 KB |
testcase_31 | AC | 32 ms
36,476 KB |
testcase_32 | AC | 26 ms
28,000 KB |
testcase_33 | AC | 27 ms
27,904 KB |
testcase_34 | AC | 37 ms
42,752 KB |
testcase_35 | AC | 36 ms
40,492 KB |
testcase_36 | AC | 5 ms
6,272 KB |
testcase_37 | AC | 5 ms
6,016 KB |
testcase_38 | AC | 38 ms
46,592 KB |
testcase_39 | AC | 19 ms
17,168 KB |
testcase_40 | AC | 37 ms
42,372 KB |
testcase_41 | AC | 13 ms
12,752 KB |
testcase_42 | AC | 27 ms
27,020 KB |
testcase_43 | AC | 21 ms
18,304 KB |
testcase_44 | AC | 27 ms
28,312 KB |
testcase_45 | AC | 25 ms
25,284 KB |
testcase_46 | AC | 15 ms
13,816 KB |
testcase_47 | AC | 26 ms
26,964 KB |
testcase_48 | AC | 29 ms
31,252 KB |
testcase_49 | AC | 38 ms
42,396 KB |
testcase_50 | AC | 32 ms
36,476 KB |
testcase_51 | AC | 30 ms
33,128 KB |
testcase_52 | AC | 9 ms
9,400 KB |
testcase_53 | AC | 13 ms
11,952 KB |
testcase_54 | AC | 34 ms
40,464 KB |
testcase_55 | AC | 15 ms
14,336 KB |
testcase_56 | AC | 42 ms
50,344 KB |
testcase_57 | AC | 33 ms
35,316 KB |
testcase_58 | AC | 48 ms
57,184 KB |
testcase_59 | AC | 46 ms
57,096 KB |
testcase_60 | AC | 44 ms
57,052 KB |
testcase_61 | AC | 42 ms
57,056 KB |
testcase_62 | AC | 37 ms
56,968 KB |
testcase_63 | AC | 3 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; }