結果

問題 No.1558 Derby Live
ユーザー 👑 NachiaNachia
提出日時 2021-06-25 21:33:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 1,137 bytes
コンパイル時間 944 ms
コンパイル使用メモリ 80,248 KB
実行使用メモリ 6,180 KB
最終ジャッジ日時 2023-09-07 14:16:30
合計ジャッジ時間 5,757 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
5,884 KB
testcase_01 AC 85 ms
5,892 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 51 ms
4,376 KB
testcase_04 AC 21 ms
4,616 KB
testcase_05 AC 21 ms
4,884 KB
testcase_06 AC 41 ms
4,540 KB
testcase_07 AC 3 ms
4,620 KB
testcase_08 AC 38 ms
5,952 KB
testcase_09 AC 43 ms
5,856 KB
testcase_10 AC 43 ms
6,180 KB
testcase_11 AC 46 ms
5,936 KB
testcase_12 AC 49 ms
5,936 KB
testcase_13 AC 51 ms
6,008 KB
testcase_14 AC 54 ms
5,972 KB
testcase_15 AC 57 ms
5,896 KB
testcase_16 AC 60 ms
5,968 KB
testcase_17 AC 62 ms
5,892 KB
testcase_18 AC 64 ms
6,012 KB
testcase_19 AC 68 ms
6,012 KB
testcase_20 AC 71 ms
5,936 KB
testcase_21 AC 67 ms
5,900 KB
testcase_22 AC 70 ms
5,896 KB
testcase_23 AC 72 ms
5,896 KB
testcase_24 AC 66 ms
5,940 KB
testcase_25 AC 68 ms
5,888 KB
testcase_26 AC 70 ms
5,876 KB
testcase_27 AC 66 ms
5,896 KB
testcase_28 AC 69 ms
5,896 KB
testcase_29 AC 71 ms
5,880 KB
testcase_30 AC 68 ms
5,940 KB
testcase_31 AC 70 ms
6,012 KB
testcase_32 AC 73 ms
5,896 KB
testcase_33 AC 1 ms
4,384 KB
testcase_34 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <atcoder/segtree>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)


struct S {
  int P[18];
};
S op(S l, S r) {
  rep(i,18) l.P[i] = r.P[l.P[i]];
  return l;
}
S e() {
  S res;
  rep(i,18) res.P[i] = i;
  return res;
}
using RQ = atcoder::segtree<S, op, e>;


int main(){
  int N,M,Q;
  cin >> N >> M >> Q;
  RQ G(M);
  while(Q--){
    int t; cin >> t;
    if(t == 1){
      int d; cin >> d; d--;
      S v = e(); rep(i,N){ cin >> v.P[i]; v.P[i]--; }
      G.set(d,v);
    }
    if(t == 2){
      int d; cin >> d;
      S res = G.prod(0,d);
      int ans[18];
      rep(i,N) ans[res.P[i]] = i + 1;
      rep(i,N){
        if(i != 0) cout << " ";
        cout << ans[i];
      }
      cout << "\n";
    }
    if(t == 3){
      int l,r; cin >> l >> r; l--;
      S res = G.prod(l,r);
      int ans = 0;
      rep(i,N) ans += abs(i-res.P[i]);
      cout << ans << "\n";
    }
  }
  return 0;
}

struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_inst;
0