結果

問題 No.1558 Derby Live
ユーザー trineutrontrineutron
提出日時 2021-06-25 21:57:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 1,591 bytes
コンパイル時間 2,098 ms
コンパイル使用メモリ 203,568 KB
実行使用メモリ 6,220 KB
最終ジャッジ日時 2023-09-07 14:29:36
合計ジャッジ時間 9,027 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
6,052 KB
testcase_01 AC 165 ms
6,012 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 116 ms
4,376 KB
testcase_04 AC 54 ms
4,628 KB
testcase_05 AC 58 ms
5,156 KB
testcase_06 AC 102 ms
4,636 KB
testcase_07 AC 3 ms
4,692 KB
testcase_08 AC 98 ms
5,944 KB
testcase_09 AC 103 ms
6,056 KB
testcase_10 AC 106 ms
6,012 KB
testcase_11 AC 109 ms
6,024 KB
testcase_12 AC 112 ms
5,884 KB
testcase_13 AC 121 ms
5,956 KB
testcase_14 AC 120 ms
6,076 KB
testcase_15 AC 131 ms
6,068 KB
testcase_16 AC 136 ms
6,220 KB
testcase_17 AC 143 ms
5,904 KB
testcase_18 AC 142 ms
6,072 KB
testcase_19 AC 147 ms
5,964 KB
testcase_20 AC 149 ms
6,064 KB
testcase_21 AC 144 ms
6,056 KB
testcase_22 AC 148 ms
6,072 KB
testcase_23 AC 152 ms
5,952 KB
testcase_24 AC 138 ms
6,000 KB
testcase_25 AC 142 ms
5,948 KB
testcase_26 AC 149 ms
6,004 KB
testcase_27 AC 144 ms
6,056 KB
testcase_28 AC 161 ms
6,072 KB
testcase_29 AC 159 ms
6,072 KB
testcase_30 AC 143 ms
6,076 KB
testcase_31 AC 145 ms
6,072 KB
testcase_32 AC 150 ms
6,072 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;
using namespace atcoder;

using S = array<int, 18>;

S op(S a, S b)
{
    S res;
    for (int i = 0; i < 18; i++)
    {
        res.at(i) = b.at(a.at(i));
    }
    return res;
}

S e()
{
    S res;
    iota(res.begin(), res.end(), 0);
    return res;
}

int fun(S a)
{
    int res = 0;
    for (int i = 0; i < 18; i++)
    {
        res += abs(i - a.at(i));
    }
    return res;
}

int main()
{
    int n, m, q;
    cin >> n >> m >> q;
    segtree<S, op, e> seg(m);
    for (int i = 0; i < q; i++)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            int d;
            cin >> d;
            d--;
            S p = e();
            for (int j = 0; j < n; j++)
            {
                cin >> p.at(j);
                p.at(j)--;
            }
            seg.set(d, p);
        }
        else if (t == 2)
        {
            int s;
            cin >> s;
            S res = seg.prod(0, s), ans;
            for (int j = 0; j < 18; j++)
            {
                ans.at(res.at(j)) = j;
            }
            for (int j = 0; j < n; j++)
            {
                cout << ans.at(j) + 1;
                if (j < n - 1)
                {
                    cout << ' ';
                }
                else
                {
                    cout << '\n';
                }
            }
        }
        else
        {
            int l, r;
            cin >> l >> r;
            l--;
            cout << fun(seg.prod(l, r)) << '\n';
        }
    }
    return 0;
}
0