結果

問題 No.1558 Derby Live
ユーザー hir355hir355
提出日時 2021-06-25 22:59:22
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 2,371 bytes
コンパイル時間 2,471 ms
コンパイル使用メモリ 208,092 KB
実行使用メモリ 7,724 KB
最終ジャッジ日時 2023-09-07 14:53:29
合計ジャッジ時間 9,745 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 162 ms
7,556 KB
testcase_01 AC 170 ms
7,620 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 120 ms
4,380 KB
testcase_04 AC 64 ms
4,384 KB
testcase_05 AC 78 ms
4,416 KB
testcase_06 AC 123 ms
4,624 KB
testcase_07 AC 6 ms
4,684 KB
testcase_08 AC 122 ms
5,360 KB
testcase_09 AC 131 ms
6,012 KB
testcase_10 AC 135 ms
5,904 KB
testcase_11 AC 132 ms
6,020 KB
testcase_12 AC 139 ms
6,020 KB
testcase_13 AC 139 ms
6,676 KB
testcase_14 AC 144 ms
6,760 KB
testcase_15 AC 152 ms
6,968 KB
testcase_16 AC 156 ms
6,964 KB
testcase_17 AC 163 ms
7,724 KB
testcase_18 AC 165 ms
7,576 KB
testcase_19 AC 164 ms
7,572 KB
testcase_20 AC 173 ms
7,520 KB
testcase_21 AC 161 ms
7,524 KB
testcase_22 AC 165 ms
7,228 KB
testcase_23 AC 168 ms
7,312 KB
testcase_24 AC 158 ms
7,540 KB
testcase_25 AC 169 ms
7,228 KB
testcase_26 AC 172 ms
7,264 KB
testcase_27 AC 158 ms
7,256 KB
testcase_28 AC 163 ms
7,232 KB
testcase_29 AC 168 ms
7,288 KB
testcase_30 AC 158 ms
7,264 KB
testcase_31 AC 165 ms
7,620 KB
testcase_32 AC 168 ms
7,528 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/segtree>
#include <bits/stdc++.h>

using namespace std;
using namespace atcoder;

constexpr long long INF_LL = 2000000000000000000LL;
constexpr int INF = 2000000000;
constexpr long long MOD = 1000000007;

#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;

int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};

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

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

struct edge {
    int to;
    ll cost;
    ll d;
    edge(int t, ll c, ll dd) { to = t, cost = c, d = dd; }
};

typedef vector<vector<edge>> graph;

//using mint = modint1000000007;

int n;

vector<int> op(vector<int> x, vector<int> y){
    vector<int> res(n);
    rep(i, n){
        res[i] = y[x[i]];
    }
    return res;
};
vector<int> e(){
    vector<int> res(n);
    rep(i, n) res[i] = i;
    return res;
};

int main(){
    cin.tie(0);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(16);

    int m, q;
    cin >> n >> m >> q;

    segtree<vector<int>, op, e> seg(m);
    rep(_, q){
        int t;
        cin >> t;
        if(t == 1){
            int d;
            cin >> d;
            vector<int> p(n);
            rep(i, n) {
                cin >> p[i];
                p[i]--;
            }
            seg.set(d - 1, p);
        }else if(t == 2){
            int s;
            cin >> s;
            auto l = seg.prod(0, s);
            vector<int> res(n);
            rep(i, n) res[l[i]] = i;
            cout << res[0] + 1;
            rep(i, n - 1) cout << " " << res[i + 1] + 1;
            cout << endl;
        }else{
            int x, y;
            cin >> x >> y;
            auto l = seg.prod(x - 1, y);
            int ans = 0;
            rep(i, n) ans += abs(i - l[i]);
            cout << ans << endl;
        }
    }
}
0