Блог пользователя -is-this-dp

Автор -is-this-dp, история, 6 месяцев назад, По-английски

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$$$

Полный текст и комментарии »

  • Проголосовать: нравится
  • +16
  • Проголосовать: не нравится