結果
問題 | No.1558 Derby Live |
ユーザー | sten_san |
提出日時 | 2022-04-21 18:35:07 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 105 ms / 2,000 ms |
コード長 | 4,805 bytes |
コンパイル時間 | 2,373 ms |
コンパイル使用メモリ | 207,772 KB |
実行使用メモリ | 9,344 KB |
最終ジャッジ日時 | 2024-06-22 21:47:40 |
合計ジャッジ時間 | 8,512 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 91 ms
9,156 KB |
testcase_01 | AC | 105 ms
9,204 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 82 ms
5,376 KB |
testcase_04 | AC | 39 ms
6,656 KB |
testcase_05 | AC | 47 ms
6,656 KB |
testcase_06 | AC | 78 ms
6,144 KB |
testcase_07 | AC | 4 ms
6,016 KB |
testcase_08 | AC | 74 ms
9,088 KB |
testcase_09 | AC | 75 ms
9,088 KB |
testcase_10 | AC | 78 ms
9,216 KB |
testcase_11 | AC | 80 ms
9,136 KB |
testcase_12 | AC | 88 ms
9,088 KB |
testcase_13 | AC | 93 ms
9,344 KB |
testcase_14 | AC | 92 ms
9,100 KB |
testcase_15 | AC | 97 ms
9,088 KB |
testcase_16 | AC | 97 ms
9,088 KB |
testcase_17 | AC | 100 ms
9,136 KB |
testcase_18 | AC | 98 ms
9,216 KB |
testcase_19 | AC | 100 ms
9,216 KB |
testcase_20 | AC | 102 ms
9,204 KB |
testcase_21 | AC | 97 ms
9,216 KB |
testcase_22 | AC | 99 ms
9,076 KB |
testcase_23 | AC | 104 ms
9,216 KB |
testcase_24 | AC | 97 ms
9,124 KB |
testcase_25 | AC | 99 ms
9,088 KB |
testcase_26 | AC | 103 ms
9,128 KB |
testcase_27 | AC | 97 ms
9,204 KB |
testcase_28 | AC | 102 ms
9,088 KB |
testcase_29 | AC | 102 ms
9,216 KB |
testcase_30 | AC | 98 ms
9,140 KB |
testcase_31 | AC | 98 ms
9,216 KB |
testcase_32 | AC | 102 ms
9,088 KB |
testcase_33 | AC | 2 ms
5,376 KB |
testcase_34 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; struct iofast_t { iofast_t() { ios::sync_with_stdio(false); cin.tie(nullptr); } } iofast; struct uns_t {} uns; template <typename Element, typename Head, typename ...Args> auto vec(Element init, Head arg, Args ...args) { if constexpr (sizeof...(Args) == 0) return vector(arg, init); else return vector(arg, vec(init, args...)); } template <typename Element, typename Head, typename ...Args> auto vec(uns_t, Head arg, Args ...args) { return vec(Element(), arg, args...); } template <typename Container> auto distance(const Container &c, decltype(begin(c)) iter) { return distance(begin(c), iter); } template <typename RIter, typename Compare = less<typename iterator_traits<RIter>::value_type>> auto isort(RIter first, RIter last, Compare comp = Compare()) { vector<int> i(distance(first, last)); iota(begin(i), end(i), 0); sort(begin(i), end(i), [&](auto x, auto y) { return comp(*(first + x), *(first + y)); }); return i; } template <typename, template <typename> typename, typename = void_t<>> struct detect : false_type {}; template <typename T, template <typename> typename Check> struct detect<T, Check, void_t<Check<T>>> : true_type {}; template <typename T, template <typename> typename Check> constexpr inline bool detect_v = detect<T, Check>::value; template <typename T> using has_member_sort = decltype(declval<T>().sort()); template <typename Container, typename Compare = less<typename Container::value_type>> auto sorted(Container c, Compare comp = Compare()) { if constexpr (detect_v<Container, has_member_sort>) { c.sort(comp); return c; } else { sort(begin(c), end(c), comp); return c; } } template <typename Container, typename Compare = equal_to<typename Container::value_type>> auto uniqued(Container c, Compare comp = Compare()) { c.erase(unique(begin(c), end(c), comp), end(c)); return c; } template <typename T, typename Compare = less<T>> T &chmin(T &l, T r, Compare &&f = less<T>()) { return l = min(l, r, f); } template <typename T, typename Compare = less<T>> T &chmax(T &l, T r, Compare &&f = less<T>()) { return l = max(l, r, f); } template <size_t N> struct sperm : std::array<int, N> { constexpr static size_t size() { return N; } template <typename ...Args> constexpr sperm(Args ...args): perm_() { static_assert((std::is_convertible_v<Args, size_t> && ...), "Could not convert to size_t"); for (size_t i = 0; i < N; ++i) { perm_[i] = i; } if constexpr (1 < sizeof...(Args)) { bool f = true; size_t p = 0, q = 0; for (auto i : { static_cast<size_t>(args)... }) { if (f) { f = false; p = i; q = i; continue; } perm_[p] = i; p = i; } perm_[p] = q; } } constexpr sperm operator *(const sperm &r) const { sperm x; for (size_t i = 0; i < N; ++i) { x[i] = perm_[r[i]]; } return x; } constexpr auto &operator [](size_t i) { return perm_[i]; } constexpr const auto &operator [](size_t i) const { return perm_[i]; } private: std::array<int, N> perm_; }; template <size_t N> auto &operator <<(std::ostream &os, const sperm<N> &sp) { os << "("; if constexpr (0 < std::size(sp)) { os << sp[0]; for (size_t i = 1; i < std::size(sp); ++i) { os << ", " << sp[i]; } } os << ")"; return os; } #include <atcoder/segtree> using rep = sperm<18>; rep op(rep x, rep y) { return y * x; } rep elem() { return {}; } using segtree = atcoder::segtree<rep, op, elem>; int main() { int n, m, q; cin >> n >> m >> q; segtree seg(m); while (q--) { int t; cin >> t; if (t == 1) { int d; cin >> d; --d; rep p; for (int i = 0; i < n; ++i) { cin >> p[i]; --p[i]; } seg.set(d, p); } if (t == 2) { int s; cin >> s; auto p = seg.prod(0, s); rep q; for (int i = 0; i < n; ++i) { q[p[i]] = i; } cout << q[0] + 1; for (int i = 1; i < n; ++i) { cout << " " << q[i] + 1; } cout << endl; } if (t == 3) { int l, r; cin >> l >> r; --l; auto p = seg.prod(l, r); int ans = 0; for (int i = 0; i < n; ++i) { ans += abs(i - p[i]); } cout << ans << endl; } } }