結果
問題 | No.1013 〇マス進む |
ユーザー | kcvlex |
提出日時 | 2020-03-20 22:23:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 3,123 bytes |
コンパイル時間 | 1,760 ms |
コンパイル使用メモリ | 175,536 KB |
実行使用メモリ | 57,180 KB |
最終ジャッジ日時 | 2024-12-15 06:39:06 |
合計ジャッジ時間 | 6,623 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
13,656 KB |
testcase_01 | AC | 5 ms
13,664 KB |
testcase_02 | AC | 4 ms
13,664 KB |
testcase_03 | AC | 5 ms
14,060 KB |
testcase_04 | AC | 5 ms
13,808 KB |
testcase_05 | AC | 4 ms
14,068 KB |
testcase_06 | AC | 4 ms
13,932 KB |
testcase_07 | AC | 5 ms
13,940 KB |
testcase_08 | AC | 5 ms
13,936 KB |
testcase_09 | AC | 5 ms
14,064 KB |
testcase_10 | AC | 4 ms
13,808 KB |
testcase_11 | AC | 5 ms
13,808 KB |
testcase_12 | AC | 5 ms
13,964 KB |
testcase_13 | AC | 6 ms
15,284 KB |
testcase_14 | AC | 27 ms
34,028 KB |
testcase_15 | AC | 35 ms
47,216 KB |
testcase_16 | AC | 34 ms
44,228 KB |
testcase_17 | AC | 24 ms
32,096 KB |
testcase_18 | AC | 28 ms
36,240 KB |
testcase_19 | AC | 21 ms
26,968 KB |
testcase_20 | AC | 42 ms
54,412 KB |
testcase_21 | AC | 26 ms
23,948 KB |
testcase_22 | AC | 29 ms
31,888 KB |
testcase_23 | AC | 13 ms
12,524 KB |
testcase_24 | AC | 42 ms
56,072 KB |
testcase_25 | AC | 41 ms
55,040 KB |
testcase_26 | AC | 13 ms
12,572 KB |
testcase_27 | AC | 22 ms
22,700 KB |
testcase_28 | AC | 13 ms
12,572 KB |
testcase_29 | AC | 41 ms
53,424 KB |
testcase_30 | AC | 22 ms
20,736 KB |
testcase_31 | AC | 30 ms
36,356 KB |
testcase_32 | AC | 25 ms
27,880 KB |
testcase_33 | AC | 27 ms
28,004 KB |
testcase_34 | AC | 37 ms
42,808 KB |
testcase_35 | AC | 35 ms
40,492 KB |
testcase_36 | AC | 6 ms
6,144 KB |
testcase_37 | AC | 6 ms
5,888 KB |
testcase_38 | AC | 39 ms
46,720 KB |
testcase_39 | AC | 20 ms
17,164 KB |
testcase_40 | AC | 38 ms
42,496 KB |
testcase_41 | AC | 14 ms
12,884 KB |
testcase_42 | AC | 27 ms
26,892 KB |
testcase_43 | AC | 21 ms
18,304 KB |
testcase_44 | AC | 27 ms
28,192 KB |
testcase_45 | AC | 25 ms
25,088 KB |
testcase_46 | AC | 15 ms
13,696 KB |
testcase_47 | AC | 26 ms
26,880 KB |
testcase_48 | AC | 29 ms
31,256 KB |
testcase_49 | AC | 38 ms
42,296 KB |
testcase_50 | AC | 32 ms
36,480 KB |
testcase_51 | AC | 30 ms
33,004 KB |
testcase_52 | AC | 10 ms
9,176 KB |
testcase_53 | AC | 13 ms
11,816 KB |
testcase_54 | AC | 34 ms
40,340 KB |
testcase_55 | AC | 16 ms
14,184 KB |
testcase_56 | AC | 42 ms
50,216 KB |
testcase_57 | AC | 33 ms
35,072 KB |
testcase_58 | AC | 47 ms
57,180 KB |
testcase_59 | AC | 47 ms
57,056 KB |
testcase_60 | AC | 45 ms
57,080 KB |
testcase_61 | AC | 42 ms
57,052 KB |
testcase_62 | AC | 38 ms
56,960 KB |
testcase_63 | AC | 3 ms
5,248 KB |
testcase_64 | AC | 3 ms
5,248 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; }