-is-this-dp's blog

By -is-this-dp, history, 5 months ago, In English

Can this problem be solved under the standard Time limits ? How ?

Given a multiset of $$$N$$$ pairs, answer $$$Q$$$ queries

A query can be of two types:

$$$1$$$ $$$x$$$ $$$y$$$: add pair $$$(x, y)$$$ to the multiset

$$$2$$$ $$$v$$$: return a pair where both $$$x$$$ and $$$y$$$ are not equal to $$$v$$$ or return $$$-1$$$ if there's no pair where both coordinates are not equal to $$$v$$$

$$$1 ≤ N,Q ≤ 1e5 $$$

Sample Input:

$$$N=2$$$ $$$Q=3$$$

Pairs: $$$(1,2)$$$ $$$(2,2)$$$

queries:

$$$2$$$ $$$2$$$

$$$1$$$ $$$(3, 4)$$$

$$$2$$$ $$$2$$$

Sample Output:

$$$-1$$$ : Because no pairs have both coordinates $$$!= 2$$$

$$$(3,4)$$$ : This was inserted in previous query and has both coordinates $$$!= 2$$$

Full text and comments »

  • Vote: I like it
  • +16
  • Vote: I do not like it