結果
問題 | No.1558 Derby Live |
ユーザー |
![]() |
提出日時 | 2021-06-25 21:57:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 184 ms / 2,000 ms |
コード長 | 1,591 bytes |
コンパイル時間 | 2,420 ms |
コンパイル使用メモリ | 199,100 KB |
最終ジャッジ日時 | 2025-01-22 12:13:24 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 33 |
ソースコード
#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; }