ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1839. The Mentaculus

Some hints.
Posted by Bliss 2 Oct 2018 18:17
You can solve the problem without using floating point calculations. in32 is enough for everything.

You also needn't to implement BSTrees or Segment trees here. Using ordered sets is enough.

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

typedef __gnu_pbds::tree<
  Point,
  __gnu_pbds::null_type,
  std::less_equal<>,
  __gnu_pbds::rb_tree_tag,
  __gnu_pbds::tree_order_statistics_node_update> ordered_set_less;

typedef __gnu_pbds::tree<
  Point,
  __gnu_pbds::null_type,
  std::greater_equal<>,
  __gnu_pbds::rb_tree_tag,
  __gnu_pbds::tree_order_statistics_node_update> ordered_set_greater;