Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct 🎄 🎄;
- using 🌲 = 🎄*;
- mt19937 make_gift(228);
- struct 🎄 {
- int 🕰, 🎁, 🧦;
- 🌲 l = 0;
- 🌲 r = 0;
- 🎄(int val) {
- 🕰 = val;
- 🎁 = make_gift();
- 🧦 = 1;
- }
- };
- int find_all_socks(🌲 t) {return t ? t->🧦 : 0;}
- void add🌟(🌲 t) {t->🧦 = 1 + find_all_socks(t->l) + find_all_socks(t->r);}
- void 🎄🎄(🌲 l, 🌲 r, 🌲&t) {
- if (!l || !r) t = l ? l : r;
- else if (l->🎁 > r->🎁) 🎄🎄(l->r, r, l->r), t = l, add🌟(t);
- else 🎄🎄(l, r->l, r->l), t = r, add🌟(t);
- }
- void schedule_New_Year(🌲 t, int time, 🌲&l, 🌲&r) {
- if (!t) l = r = 0;
- else if (t->🕰 > time) schedule_New_Year(t->l, time, l, t->l), r = t, add🌟(r);
- else schedule_New_Year(t->r, time, t->r, r), l = t, add🌟(l);
- }
Advertisement
Add Comment
Please, Sign In to add comment