제출 #671080

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
6710802022-12-11 22:56:29SirCovidThe19thIndex (COCI21_index)C++17
110 / 110
1266 ms58688 KiB
#include <bits/stdc++.h>
using namespace std;
template<class T, int sz> struct persistentSegTree{
static const int maxSz = sz * 31;
T seg[maxSz]; int idx = 1, lc[maxSz], rc[maxSz];
void dup(int &i){
lc[idx] = lc[i];
rc[idx] = rc[i];
seg[idx] = seg[i];
i = idx; idx++;
}
void upd(int p, int &i, int l = 0, int r = 2e5 + 5){
dup(i);
if (l == r){ seg[i] = 1; return; }
int mid = (l + r) / 2;
if (p <= mid) upd(p, lc[i], l, mid);
else upd(p, rc[i], mid + 1, r);
seg[i] = seg[lc[i]] + seg[rc[i]];
}
T qry(int ql, int qr, int i, int l = 0, int r = 2e5 + 5){
if (qr < l or ql > r or !i) return 0;
if (l >= ql and r <= qr) return seg[i];
int mid = (l + r) / 2;
return qry(ql, qr, lc[i], l, mid) + qry(ql, qr, rc[i], mid + 1, r);
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...