제출 #885349

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
8853492023-12-09 14:01:02Koyote운세 보기 2 (JOI14_fortune_telling2)C++11
100 / 100
615 ms222580 KiB
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
// Persistent Segment Tree
struct node {
node *l, *r;
int val;
node() : l(0), r(0), val(0) {}
node(int _v) : l(0), r(0), val(_v) {}
node(node *_l, node *_r) : l(_l), r(_r), val(l->val + r->val) {}
void extend() {
if (!l) l = new node();
if (!r) r = new node();
}
};
node* update(node *cur, int p, int v, int l, int r) {
if (l == r) return new node(cur->val + v);
cur->extend();
int mid = (l + r) >> 1;
if (p <= mid) return new node(update(cur->l, p, v, l, mid), cur->r);
else return new node(cur->l, update(cur->r, p, v, mid + 1, r));
}
int query(node *cur, int qs, int qe, int l, int r) {
if (r < qs || qe < l) return 0;
if (qs <= l && r <= qe) return cur->val;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...