結果
問題 | No.1558 Derby Live |
ユーザー |
![]() |
提出日時 | 2021-06-25 21:42:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 79 ms / 2,000 ms |
コード長 | 1,549 bytes |
コンパイル時間 | 3,657 ms |
コンパイル使用メモリ | 255,064 KB |
最終ジャッジ日時 | 2025-01-22 12:08:21 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 33 |
ソースコード
#include<bits/stdc++.h>#include<atcoder/all>using namespace std;using namespace atcoder;#define rep(i,n)for (int i = 0; i < int(n); ++i)#define rrep(i,n)for (int i = int(n)-1; i >= 0; --i)#define all(x) (x).begin(), (x).end()#define rall(x) (x).rbegin(), (x).rend()template<class T> void chmax(T& a, const T& b) {a = max(a, b);}template<class T> void chmin(T& a, const T& b) {a = min(a, b);}using ll = long long;using P = pair<int,int>;using VI = vector<int>;using VVI = vector<VI>;using VL = vector<ll>;using VVL = vector<VL>;int n;struct S {int d[18];};S op(S f, S g) {S h; // h = f;grep(i, n) h.d[i] = g.d[f.d[i]];return h;}S e() {S f;rep(i, 18) f.d[i] = i;return f;}int main() {ios::sync_with_stdio(false);cin.tie(0);int m, q;cin >> n >> m >> q;segtree<S, op, e> seg(q);rep(_, q) {int type;cin >> type;if (type == 1) {int d;cin >> d, d--;S p;rep(i, n) cin >> p.d[i], p.d[i]--;seg.set(d, p);} else if (type == 2) {int s;cin >> s;auto p = seg.prod(0, s);int rank[18];rep(i, n) rank[p.d[i]] = i;rep(i, n) cout << rank[i] + 1 << " \n"[i + 1 == n];} else {int l, r;cin >> l >> r, l--;auto p = seg.prod(l, r);int ans = 0;rep(i, n) ans += abs(i - p.d[i]);cout << ans << '\n';}}}