結果

問題 No.1558 Derby Live
ユーザー nanophoto12nanophoto12
提出日時 2021-06-26 00:18:26
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 3,417 bytes
コンパイル時間 4,304 ms
コンパイル使用メモリ 265,948 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 15:11:36
合計ジャッジ時間 11,349 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
4,380 KB
testcase_01 AC 179 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 133 ms
4,376 KB
testcase_04 AC 53 ms
4,376 KB
testcase_05 AC 61 ms
4,380 KB
testcase_06 AC 110 ms
4,376 KB
testcase_07 AC 3 ms
4,384 KB
testcase_08 AC 100 ms
4,380 KB
testcase_09 AC 106 ms
4,376 KB
testcase_10 AC 109 ms
4,384 KB
testcase_11 AC 116 ms
4,380 KB
testcase_12 AC 119 ms
4,376 KB
testcase_13 AC 126 ms
4,380 KB
testcase_14 AC 129 ms
4,380 KB
testcase_15 AC 137 ms
4,376 KB
testcase_16 AC 142 ms
4,380 KB
testcase_17 AC 149 ms
4,380 KB
testcase_18 AC 153 ms
4,380 KB
testcase_19 AC 160 ms
4,380 KB
testcase_20 AC 166 ms
4,380 KB
testcase_21 AC 156 ms
4,380 KB
testcase_22 AC 163 ms
4,380 KB
testcase_23 AC 166 ms
4,380 KB
testcase_24 AC 154 ms
4,376 KB
testcase_25 AC 160 ms
4,380 KB
testcase_26 AC 167 ms
4,380 KB
testcase_27 AC 153 ms
4,376 KB
testcase_28 AC 160 ms
4,380 KB
testcase_29 AC 166 ms
4,380 KB
testcase_30 AC 155 ms
4,380 KB
testcase_31 AC 159 ms
4,376 KB
testcase_32 AC 164 ms
4,380 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,n) for(ll a = n - 1;a >= 0;a--)

template<typename T>
void chmax(T& reference, T value) {
    reference = max(reference, value);
}

template<typename T>
void chmaxmap(map<T, T>& m, T key, T value) {
    if (m.count(key)) {
        chmax(m[key], value);
    }
    else {
        m[key] = value;
    }
}

template<typename T>
void chmin(T& reference, T value) {
    reference = min(reference, value);
}

#include <atcoder/all>

using namespace atcoder;

typedef modint1000000007 mint;

constexpr ll mod = 1000000007;

constexpr ll mpow(ll x, ll n) {
    ll ans = 1; x %= mod;
    while (n != 0) {
        if (n & 1) ans = ans * x % mod;
        x = x * x % mod;
        n = n >> 1;
    }
    return ans;
}

class Primes {
private:
	vector<int> Prime_Number;
	vector<bool> is_prime_;
public:
	Primes(int N) {
		is_prime_.resize(N + 1, true);
		is_prime_[0] = is_prime_[1] = false;
		for (int i = 0; i < N + 1; i++) {
			if (is_prime_[i]) {
				Prime_Number.push_back(i);
				for (int j = 2 * i; j <= N; j += i) is_prime_[j] = false;
			}
		}
	}
	int operator[](int i) { return Prime_Number[i]; }
	int size() { return Prime_Number.size(); }
	int back() { return Prime_Number.back(); }
	bool isPrime(int q) { return is_prime_[q]; }
};

class SDivisor {
public:
	vector<ll> F;

	SDivisor(ll N) {
		for (ll i = 1; i * i <= N; i++) {
			if (N % i == 0) {
				F.push_back(i);
				if (i * i != N) F.push_back(N / i);
			}
		}
		sort(begin(F), end(F));
	}
	int size() { return F.size(); }
	ll operator[](int k) { return F[k]; }
	const vector<ll>& factors() { return F; }
};

class Divisor {
private:
	vector<ll> F;
	vector<pair<ll, ll>> pfactorize;
public:
	Divisor(ll N) {
		for (ll i = 1; i * i <= N; i++) {
			if (N % i == 0) {
				F.push_back(i);
				if (i * i != N) F.push_back(N / i);
			}
		}
		sort(begin(F), end(F));
		Primes p((ll)sqrt(N) + 1);
		for (int i = 0; i < p.size(); i++) {
			pfactorize.emplace_back(p[i], 0);
			while (N % p[i] == 0) {
				N /= p[i];
				pfactorize.back().second++;
			}
			if (pfactorize.back().second == 0) pfactorize.pop_back();
		}
		if (N > 1) pfactorize.emplace_back(N, 1);
	}
	int size() { return F.size(); }
	const vector<pair<ll, ll>>& pfac() { return pfactorize; }
	ll operator[](int k) { return F[k]; }
	const vector<ll>& factors() { return F; }
};

ll n, m, q;

struct S {
	uint8_t t[18];
	S() {
		for (int i = 0; i < 18; i++) {
			t[i] = i;
		}
	}
};

S op(S left, S right) {
	S c;
	for (int i = 0; i < n; i++) {
		c.t[i] = left.t[right.t[i]];
	}
	return c;
}

S e() {
	return S();
}

int main() {
	cin >> n >> m >> q;
	atcoder::segtree<S, op, e> tree1(m);
	rep(i, q) {
		int id;
		cin >> id;
		if (id == 1) {
			int d; cin >> d; d--;
			S s;
			ll t = 0;
			rep(j, n) {
				int x; cin >> x; x--;
				s.t[x] = j;
			}
			tree1.set(d, s);
		}
		if (id == 2) {
			int s; cin >> s; s--;
			auto u = tree1.prod(0, s + 1);
			rep(j, n) {
				cout << u.t[j] + 1 << " ";
			}
			cout << endl;
		}
		if (id == 3) {
			int l, r; cin >> l >> r; l--;
			auto s = tree1.prod(l, r);
			ll sum = 0;
			rep(j, n) {
				sum += abs(s.t[j] - j);
			}
			cout << sum << endl;
		}
	}
    return 0;
}
0