結果

問題 No.2942 Sigma Music Game Level Problem
ユーザー a1048576a1048576
提出日時 2024-10-18 21:47:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,445 bytes
コンパイル時間 4,956 ms
コンパイル使用メモリ 236,960 KB
実行使用メモリ 19,960 KB
最終ジャッジ日時 2024-10-18 22:37:13
合計ジャッジ時間 25,218 ms
ジャッジサーバーID
(参考情報)
judge1 / judge
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 14 ms
19,716 KB
testcase_02 WA -
testcase_03 AC 12 ms
19,772 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 1,207 ms
19,724 KB
testcase_22 AC 1,128 ms
19,800 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all> 
using mint = atcoder::modint998244353;
#define int long long
struct Segtree {
  vector<vector<int>> num;
  vector<int> p;
  int n;
  Segtree(int N) {
    n = N;
    num.resize(n);
    p.resize(n+1);
    p[0] = 1;
    for(int i = 0; i < n; i++) p[i+1] = p[i]*2;
    for(int i = 0; i < n; i++) num[i].assign(p[i],0);
  }
  void add(int x, int y) {
    num[n-1][x] = num[n-1][x]+y;
    int t = x;
    for(int i = n-2; i >= 0; i--) {
      t/=2;
      num[i][t] = num[i+1][t*2]+num[i+1][t*2+1];
    }
  }
  int sum_calc(int t, int l, int r, int x, int y) {
    int m = (l+r)/2;
    if(t == n) return 0;
    if(x <= l && r <= y) return num[t][l/p[n-t-1]];
    if(r <= x || y <= l) return 0;
    return sum_calc(t+1,l,m,x,y)+sum_calc(t+1,m,r,x,y);
  }
  int sum(int l, int r) {
    return sum_calc(0,0,p[n-1],l,r);
  }
};

signed main() {
  int n,Q,L;
  cin >> n >> Q >> L;
  Segtree f(20),g(20);
  for(int i = 0; i < n; i++) {
    int x;
    cin >> x;
    f.add(x,1);
    g.add(x,x);
  }
  string ans = "Not Found!";
  while(Q--) {
    int t;
    cin >> t;
    if(t == 1) {
      int x;
      cin >> x;
      f.add(x,1);
      g.add(x,x);
    }
    else if(t == 2) {
      int l,r;
      cin >> l >> r;
      r++;
      cout << f.sum(l,r) << ' ' << g.sum(l,r) << endl;
      ans = "";
    }
    else {
      int x;
      cin >> x;
      continue;
    }
  }
  cout << ans << endl;
}
0