結果
問題 | No.1558 Derby Live |
ユーザー | hir355 |
提出日時 | 2021-06-25 22:59:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 239 ms / 2,000 ms |
コード長 | 2,371 bytes |
コンパイル時間 | 2,350 ms |
コンパイル使用メモリ | 207,304 KB |
最終ジャッジ日時 | 2025-01-22 12:33:48 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 33 |
ソースコード
#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; } } }