Problem about pairs
Difference between en1 and en2, changed 264 character(s)
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 &le N,Q &le 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$

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English -is-this-dp 2025-11-23 21:17:12 264 Tiny change: 'le 1e5 $\n' -> 'le 1e5 $\n\nSample input:\n'
en1 English -is-this-dp 2025-11-23 21:11:53 393 Initial revision (published)