結果

問題 No.1558 Derby Live
ユーザー Ricky_ponRicky_pon
提出日時 2021-06-25 22:13:12
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 2,684 bytes
コンパイル時間 2,359 ms
コンパイル使用メモリ 209,308 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2023-09-07 14:35:13
合計ジャッジ時間 8,517 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
7,332 KB
testcase_01 AC 143 ms
7,268 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 84 ms
4,380 KB
testcase_04 AC 41 ms
4,504 KB
testcase_05 AC 44 ms
4,380 KB
testcase_06 AC 76 ms
4,764 KB
testcase_07 AC 5 ms
4,632 KB
testcase_08 AC 76 ms
5,408 KB
testcase_09 AC 80 ms
6,092 KB
testcase_10 AC 83 ms
5,936 KB
testcase_11 AC 88 ms
5,936 KB
testcase_12 AC 90 ms
5,960 KB
testcase_13 AC 96 ms
6,672 KB
testcase_14 AC 99 ms
6,804 KB
testcase_15 AC 103 ms
6,728 KB
testcase_16 AC 108 ms
6,700 KB
testcase_17 AC 116 ms
7,248 KB
testcase_18 AC 116 ms
7,264 KB
testcase_19 AC 124 ms
7,424 KB
testcase_20 AC 127 ms
7,196 KB
testcase_21 AC 116 ms
7,240 KB
testcase_22 AC 126 ms
7,384 KB
testcase_23 AC 129 ms
7,332 KB
testcase_24 AC 118 ms
7,368 KB
testcase_25 AC 125 ms
7,240 KB
testcase_26 AC 129 ms
7,268 KB
testcase_27 AC 118 ms
7,360 KB
testcase_28 AC 124 ms
7,200 KB
testcase_29 AC 127 ms
7,356 KB
testcase_30 AC 116 ms
7,332 KB
testcase_31 AC 124 ms
7,416 KB
testcase_32 AC 127 ms
7,248 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/segtree>

#define For(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rFor(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second

using namespace std;

typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

template <typename T>
struct coord_comp {
    vector<T> v;
    bool sorted = false;

    coord_comp() {}

    int size() { return v.size(); }

    void add(T x) { v.push_back(x); }

    void build() {
        sort(v.begin(), v.end());
        v.erase(unique(v.begin(), v.end()), v.end());
        sorted = true;
    }

    int get_idx(T x) {
        assert(sorted);
        return lower_bound(v.begin(), v.end(), x) - v.begin();
    }

    T &operator[](int i) { return v[i]; }
};

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

using namespace atcoder;

int n, m, q;

vector<int> op(vector<int> a, vector<int> b) {
    rep(i, a.size()) a[i] = b[a[i]];
    return a;
}

vector<int> e() {
    vector<int> ret(n, 0);
    iota(ret.begin(), ret.end(), 0);
    return ret;
}

int main() {
    scanf("%d%d%d", &n, &m, &q);
    segtree<vector<int>, op, e> st(vector<vector<int>>(m, e()));
    rep(_, q) {
        int t;
        scanf("%d", &t);
        if (t == 1) {
            int d;
            scanf("%d", &d);
            --d;
            vector<int> tmp(n);
            rep(i, n) {
                scanf("%d", &tmp[i]);
                --tmp[i];
            }
            st.set(d, tmp);
        } else if (t == 2) {
            int s;
            scanf("%d", &s);
            auto tmp = st.prod(0, s);
            vector<int> ans(n);
            rep(i, n) ans[tmp[i]] = i;
            for (auto x : ans) printf("%d ", x + 1);
            printf("\n");
        } else {
            int l, r;
            scanf("%d%d", &l, &r);
            --l;
            auto tmp = st.prod(l, r);
            int ans = 0;
            rep(i, n) ans += abs(i - tmp[i]);
            printf("%d\n", ans);
        }
    }
}
0