# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
964291 | n3rm1n | Game (IOI13_game) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<iostream>
#define endl '\n'
using namespace std;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
struct segment_tree_2d
{
struct segment_tree
{
struct node
{
node *l, *r;
int val;
node()
{
l = nullptr;
r = nullptr;
val = 0;
};
node(_val)
{
l = nullptr;
r = nullptr;
val = _val;
}
};
node *root;
segment_tree *l, *r;
segment_tree()
{
root = new node(); /// ?
*l = nullptr;
*r = nullptr;
}
void merge_nodes(node *tree)
{
if(tree -> l == nullptr)
tree -> l = new node();
if(tree -> r == nullptr)
tree -> r = new node();
tree -> val = (tree -> l -> val + tree -> r -> val);
}
void update(node *tree, int l, int r, int pos, int k)
{
if(l == r)
{
tree -> val = k;
return;
}
int mid = (l + r)/2;
if(pos <= mid)
{
if(tree -> l == nullptr)
tree -> l = new node();
update(tree -> l, l, mid, pos, k);
}
else
{
if(tree -> r == nullptr)
tree -> r = new node();
update(tree -> r, mid+1, r, pos, k);
}
tree -> val = (l -> val) + (r -> val); /// merge?
}
int query(node *tree, int l, int r, int ql, int qr)
{
if(tree == nullptr)return 0;
if(ql <= l && r <= qr)return tree -> val;
if(ql > r || qr < l)return 0;
int mid = (l + r)/2;
return (query(tree -> l, l, mid, ql, qr) + query(tree -> r, mid+1, r, ql, qr));
}
void update(int pos, int x)
{
update(1, 1, n, pos, x);
}
int query(int ql, int qr)
{
return query(1, 1, n, ql, qr);
}
};
segment_tree *root;
segment_tree_2d()
{
root = new segment_tree();
}
void merge_tree(segment_tree *tree, int pos) /// opravqsh samo edna poziciq vyv vseki moment
{
if(tree -> l == nullptr)
tree -> l = new segment_tree();
if(tree -> r == nullptr)
tree -> r = new segment_tree();
int fh = tree -> l -> query()
tree -> val =
}
};
int main()
{
speed();
return 0;
}