struct tree {
int x;
tree *l, *r;
};
write_bit
write_int
// 17 --> 23, 39
// 1 17 1 23 0 0 1 39 0 0
write( tree *p ) {
if (p == 0) {
write_bit(0);
return;
}
write_bit(1);
write_int(x);
write(p->l);
write(p->r);
}
tree *read() {
int p = read_bit();
if (p == 0) {
return 0;
}
tree *res = new tree(read_int());
res->l = read();
res->r = read();
}